|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 | 11 | use fmt;
|
12 |
| -use ops::Bound::{Included, Excluded, Unbounded}; |
13 | 12 |
|
14 | 13 | /// An unbounded range. Use `..` (two dots) for its shorthand.
|
15 | 14 | ///
|
@@ -72,8 +71,7 @@ impl fmt::Debug for RangeFull {
|
72 | 71 | /// assert_eq!(arr[1..3], [ 1,2 ]); // Range
|
73 | 72 | /// }
|
74 | 73 | /// ```
|
75 |
| -#[derive(Clone, PartialEq, Eq, Hash)] |
76 |
| -// not Copy -- see #27186 |
| 74 | +#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186 |
77 | 75 | #[stable(feature = "rust1", since = "1.0.0")]
|
78 | 76 | pub struct Range<Idx> {
|
79 | 77 | /// The lower bound of the range (inclusive).
|
@@ -136,8 +134,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
|
136 | 134 | /// assert_eq!(arr[1..3], [ 1,2 ]);
|
137 | 135 | /// }
|
138 | 136 | /// ```
|
139 |
| -#[derive(Clone, PartialEq, Eq, Hash)] |
140 |
| -// not Copy -- see #27186 |
| 137 | +#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186 |
141 | 138 | #[stable(feature = "rust1", since = "1.0.0")]
|
142 | 139 | pub struct RangeFrom<Idx> {
|
143 | 140 | /// The lower bound of the range (inclusive).
|
@@ -253,16 +250,17 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
|
253 | 250 | /// assert_eq!(arr[1...2], [ 1,2 ]); // RangeInclusive
|
254 | 251 | /// }
|
255 | 252 | /// ```
|
256 |
| -#[derive(Clone, PartialEq, Eq, Hash)] |
257 |
| -// not Copy -- see #27186 |
| 253 | +#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186 |
258 | 254 | #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
259 | 255 | pub struct RangeInclusive<Idx> {
|
260 | 256 | /// The lower bound of the range (inclusive).
|
261 |
| - #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", |
| 257 | + #[unstable(feature = "inclusive_range", |
| 258 | + reason = "recently added, follows RFC", |
262 | 259 | issue = "28237")]
|
263 | 260 | pub start: Idx,
|
264 | 261 | /// The upper bound of the range (inclusive).
|
265 |
| - #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", |
| 262 | + #[unstable(feature = "inclusive_range", |
| 263 | + reason = "recently added, follows RFC", |
266 | 264 | issue = "28237")]
|
267 | 265 | pub end: Idx,
|
268 | 266 | }
|
@@ -335,7 +333,8 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
|
335 | 333 | #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
|
336 | 334 | pub struct RangeToInclusive<Idx> {
|
337 | 335 | /// The upper bound of the range (inclusive)
|
338 |
| - #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", |
| 336 | + #[unstable(feature = "inclusive_range", |
| 337 | + reason = "recently added, follows RFC", |
339 | 338 | issue = "28237")]
|
340 | 339 | pub end: Idx,
|
341 | 340 | }
|
@@ -366,158 +365,3 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
|
366 | 365 |
|
367 | 366 | // RangeToInclusive<Idx> cannot impl From<RangeTo<Idx>>
|
368 | 367 | // because underflow would be possible with (..0).into()
|
369 |
| - |
370 |
| -/// `RangeArgument` is implemented by Rust's built-in range types, produced |
371 |
| -/// by range syntax like `..`, `a..`, `..b` or `c..d`. |
372 |
| -#[stable(feature = "range_argument", since = "1.19.0")] |
373 |
| -pub trait RangeArgument<T: ?Sized> { |
374 |
| - /// Start index bound. |
375 |
| - /// |
376 |
| - /// Returns the start value as a `Bound`. |
377 |
| - /// |
378 |
| - /// # Examples |
379 |
| - /// |
380 |
| - /// ``` |
381 |
| - /// use std::ops::RangeArgument; |
382 |
| - /// use std::ops::Bound::*; |
383 |
| - /// |
384 |
| - /// assert_eq!((..10).start(), Unbounded); |
385 |
| - /// assert_eq!((3..10).start(), Included(&3)); |
386 |
| - /// ``` |
387 |
| - #[stable(feature = "range_argument", since = "1.19.0")] |
388 |
| - fn start(&self) -> Bound<&T>; |
389 |
| - |
390 |
| - /// End index bound. |
391 |
| - /// |
392 |
| - /// Returns the end value as a `Bound`. |
393 |
| - /// |
394 |
| - /// # Examples |
395 |
| - /// |
396 |
| - /// ``` |
397 |
| - /// use std::ops::RangeArgument; |
398 |
| - /// use std::ops::Bound::*; |
399 |
| - /// |
400 |
| - /// assert_eq!((3..).end(), Unbounded); |
401 |
| - /// assert_eq!((3..10).end(), Excluded(&10)); |
402 |
| - /// ``` |
403 |
| - #[stable(feature = "range_argument", since = "1.19.0")] |
404 |
| - fn end(&self) -> Bound<&T>; |
405 |
| -} |
406 |
| - |
407 |
| -#[stable(feature = "range_argument", since = "1.19.0")] |
408 |
| -impl<T: ?Sized> RangeArgument<T> for RangeFull { |
409 |
| - fn start(&self) -> Bound<&T> { |
410 |
| - Unbounded |
411 |
| - } |
412 |
| - fn end(&self) -> Bound<&T> { |
413 |
| - Unbounded |
414 |
| - } |
415 |
| -} |
416 |
| - |
417 |
| -#[stable(feature = "range_argument", since = "1.19.0")] |
418 |
| -impl<T> RangeArgument<T> for RangeFrom<T> { |
419 |
| - fn start(&self) -> Bound<&T> { |
420 |
| - Included(&self.start) |
421 |
| - } |
422 |
| - fn end(&self) -> Bound<&T> { |
423 |
| - Unbounded |
424 |
| - } |
425 |
| -} |
426 |
| - |
427 |
| -#[stable(feature = "range_argument", since = "1.19.0")] |
428 |
| -impl<T> RangeArgument<T> for RangeTo<T> { |
429 |
| - fn start(&self) -> Bound<&T> { |
430 |
| - Unbounded |
431 |
| - } |
432 |
| - fn end(&self) -> Bound<&T> { |
433 |
| - Excluded(&self.end) |
434 |
| - } |
435 |
| -} |
436 |
| - |
437 |
| -#[stable(feature = "range_argument", since = "1.19.0")] |
438 |
| -impl<T> RangeArgument<T> for Range<T> { |
439 |
| - fn start(&self) -> Bound<&T> { |
440 |
| - Included(&self.start) |
441 |
| - } |
442 |
| - fn end(&self) -> Bound<&T> { |
443 |
| - Excluded(&self.end) |
444 |
| - } |
445 |
| -} |
446 |
| - |
447 |
| -#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] |
448 |
| -impl<T> RangeArgument<T> for RangeInclusive<T> { |
449 |
| - fn start(&self) -> Bound<&T> { |
450 |
| - Included(&self.start) |
451 |
| - } |
452 |
| - fn end(&self) -> Bound<&T> { |
453 |
| - Included(&self.end) |
454 |
| - } |
455 |
| -} |
456 |
| - |
457 |
| -#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] |
458 |
| -impl<T> RangeArgument<T> for RangeToInclusive<T> { |
459 |
| - fn start(&self) -> Bound<&T> { |
460 |
| - Unbounded |
461 |
| - } |
462 |
| - fn end(&self) -> Bound<&T> { |
463 |
| - Included(&self.end) |
464 |
| - } |
465 |
| -} |
466 |
| - |
467 |
| -#[stable(feature = "range_argument", since = "1.19.0")] |
468 |
| -impl<T> RangeArgument<T> for (Bound<T>, Bound<T>) { |
469 |
| - fn start(&self) -> Bound<&T> { |
470 |
| - match *self { |
471 |
| - (Included(ref start), _) => Included(start), |
472 |
| - (Excluded(ref start), _) => Excluded(start), |
473 |
| - (Unbounded, _) => Unbounded, |
474 |
| - } |
475 |
| - } |
476 |
| - |
477 |
| - fn end(&self) -> Bound<&T> { |
478 |
| - match *self { |
479 |
| - (_, Included(ref end)) => Included(end), |
480 |
| - (_, Excluded(ref end)) => Excluded(end), |
481 |
| - (_, Unbounded) => Unbounded, |
482 |
| - } |
483 |
| - } |
484 |
| -} |
485 |
| - |
486 |
| -#[stable(feature = "range_argument", since = "1.19.0")] |
487 |
| -impl<'a, T: ?Sized + 'a> RangeArgument<T> for (Bound<&'a T>, Bound<&'a T>) { |
488 |
| - fn start(&self) -> Bound<&T> { |
489 |
| - self.0 |
490 |
| - } |
491 |
| - |
492 |
| - fn end(&self) -> Bound<&T> { |
493 |
| - self.1 |
494 |
| - } |
495 |
| -} |
496 |
| - |
497 |
| -/// An endpoint of a range of keys. |
498 |
| -/// |
499 |
| -/// # Examples |
500 |
| -/// |
501 |
| -/// `Bound`s are range endpoints: |
502 |
| -/// |
503 |
| -/// ``` |
504 |
| -/// use std::ops::RangeArgument; |
505 |
| -/// use std::ops::Bound::*; |
506 |
| -/// |
507 |
| -/// assert_eq!((..100).start(), Unbounded); |
508 |
| -/// assert_eq!((1..12).start(), Included(&1)); |
509 |
| -/// assert_eq!((1..12).end(), Excluded(&12)); |
510 |
| -/// ``` |
511 |
| -#[stable(feature = "collections_bound", since = "1.17.0")] |
512 |
| -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] |
513 |
| -pub enum Bound<T> { |
514 |
| - /// An inclusive bound. |
515 |
| - #[stable(feature = "collections_bound", since = "1.17.0")] |
516 |
| - Included(T), |
517 |
| - /// An exclusive bound. |
518 |
| - #[stable(feature = "collections_bound", since = "1.17.0")] |
519 |
| - Excluded(T), |
520 |
| - /// An infinite endpoint. Indicates that there is no bound in this direction. |
521 |
| - #[stable(feature = "collections_bound", since = "1.17.0")] |
522 |
| - Unbounded, |
523 |
| -} |
0 commit comments