1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 /// An unbounded range (`..`).
15 /// `RangeFull` is primarily used as a [slicing index], its shorthand is `..`.
16 /// It cannot serve as an [`Iterator`] because it doesn't have a starting point.
20 /// The `..` syntax is a `RangeFull`:
23 /// assert_eq!((..), std::ops::RangeFull);
26 /// It does not have an [`IntoIterator`] implementation, so you can't use it in
27 /// a `for` loop directly. This won't compile:
29 /// ```compile_fail,E0277
35 /// Used as a [slicing index], `RangeFull` produces the full array as a slice.
38 /// let arr = [0, 1, 2, 3];
39 /// assert_eq!(arr[ .. ], [0,1,2,3]); // RangeFull
40 /// assert_eq!(arr[ ..3], [0,1,2 ]);
41 /// assert_eq!(arr[1.. ], [ 1,2,3]);
42 /// assert_eq!(arr[1..3], [ 1,2 ]);
45 /// [`IntoIterator`]: ../iter/trait.Iterator.html
46 /// [`Iterator`]: ../iter/trait.IntoIterator.html
47 /// [slicing index]: ../slice/trait.SliceIndex.html
49 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
50 #[stable(feature = "rust1", since = "1.0.0")]
53 #[stable(feature = "rust1", since = "1.0.0")]
54 impl fmt::Debug for RangeFull {
55 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
60 /// A (half-open) range bounded inclusively below and exclusively above
63 /// The `Range` `start..end` contains all values with `x >= start` and
64 /// `x < end`. It is empty unless `start < end`.
69 /// assert_eq!((3..5), std::ops::Range { start: 3, end: 5 });
70 /// assert_eq!(3 + 4 + 5, (3..6).sum());
72 /// let arr = ['a', 'b', 'c', 'd'];
73 /// assert_eq!(arr[ .. ], ['a', 'b', 'c', 'd']);
74 /// assert_eq!(arr[ ..3], ['a', 'b', 'c', ]);
75 /// assert_eq!(arr[1.. ], [ 'b', 'c', 'd']);
76 /// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
79 #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
80 #[stable(feature = "rust1", since = "1.0.0")]
81 pub struct Range<Idx> {
82 /// The lower bound of the range (inclusive).
83 #[stable(feature = "rust1", since = "1.0.0")]
85 /// The upper bound of the range (exclusive).
86 #[stable(feature = "rust1", since = "1.0.0")]
90 #[stable(feature = "rust1", since = "1.0.0")]
91 impl<Idx: fmt::Debug> fmt::Debug for Range<Idx> {
92 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
93 write!(fmt, "{:?}..{:?}", self.start, self.end)
97 impl<Idx: PartialOrd<Idx>> Range<Idx> {
98 /// Returns `true` if `item` is contained in the range.
103 /// #![feature(range_contains)]
107 /// assert!(!(3..5).contains(&2));
108 /// assert!( (3..5).contains(&3));
109 /// assert!( (3..5).contains(&4));
110 /// assert!(!(3..5).contains(&5));
112 /// assert!(!(3..3).contains(&3));
113 /// assert!(!(3..2).contains(&3));
115 /// assert!( (0.0..1.0).contains(&0.5));
116 /// assert!(!(0.0..1.0).contains(&f32::NAN));
117 /// assert!(!(0.0..f32::NAN).contains(&0.5));
118 /// assert!(!(f32::NAN..1.0).contains(&0.5));
120 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
121 pub fn contains<U>(&self, item: &U) -> bool
124 U: ?Sized + PartialOrd<Idx>,
126 <Self as RangeBounds<Idx>>::contains(self, item)
129 /// Returns `true` if the range contains no items.
134 /// #![feature(range_is_empty)]
136 /// assert!(!(3..5).is_empty());
137 /// assert!( (3..3).is_empty());
138 /// assert!( (3..2).is_empty());
141 /// The range is empty if either side is incomparable:
144 /// #![feature(range_is_empty)]
146 /// use std::f32::NAN;
147 /// assert!(!(3.0..5.0).is_empty());
148 /// assert!( (3.0..NAN).is_empty());
149 /// assert!( (NAN..5.0).is_empty());
151 #[unstable(feature = "range_is_empty", reason = "recently added", issue = "48111")]
152 pub fn is_empty(&self) -> bool {
153 !(self.start < self.end)
157 /// A range only bounded inclusively below (`start..`).
159 /// The `RangeFrom` `start..` contains all values with `x >= start`.
161 /// *Note*: Currently, no overflow checking is done for the [`Iterator`]
162 /// implementation; if you use an integer range and the integer overflows, it
163 /// might panic in debug mode or create an endless loop in release mode. **This
164 /// overflow behavior might change in the future.**
169 /// assert_eq!((2..), std::ops::RangeFrom { start: 2 });
170 /// assert_eq!(2 + 3 + 4, (2..).take(3).sum());
172 /// let arr = [0, 1, 2, 3];
173 /// assert_eq!(arr[ .. ], [0,1,2,3]);
174 /// assert_eq!(arr[ ..3], [0,1,2 ]);
175 /// assert_eq!(arr[1.. ], [ 1,2,3]); // RangeFrom
176 /// assert_eq!(arr[1..3], [ 1,2 ]);
179 /// [`Iterator`]: ../iter/trait.IntoIterator.html
181 #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
182 #[stable(feature = "rust1", since = "1.0.0")]
183 pub struct RangeFrom<Idx> {
184 /// The lower bound of the range (inclusive).
185 #[stable(feature = "rust1", since = "1.0.0")]
189 #[stable(feature = "rust1", since = "1.0.0")]
190 impl<Idx: fmt::Debug> fmt::Debug for RangeFrom<Idx> {
191 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
192 write!(fmt, "{:?}..", self.start)
196 impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
197 /// Returns `true` if `item` is contained in the range.
202 /// #![feature(range_contains)]
206 /// assert!(!(3..).contains(&2));
207 /// assert!( (3..).contains(&3));
208 /// assert!( (3..).contains(&1_000_000_000));
210 /// assert!( (0.0..).contains(&0.5));
211 /// assert!(!(0.0..).contains(&f32::NAN));
212 /// assert!(!(f32::NAN..).contains(&0.5));
214 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
215 pub fn contains<U>(&self, item: &U) -> bool
218 U: ?Sized + PartialOrd<Idx>,
220 <Self as RangeBounds<Idx>>::contains(self, item)
224 /// A range only bounded exclusively above (`..end`).
226 /// The `RangeTo` `..end` contains all values with `x < end`.
227 /// It cannot serve as an [`Iterator`] because it doesn't have a starting point.
231 /// The `..end` syntax is a `RangeTo`:
234 /// assert_eq!((..5), std::ops::RangeTo { end: 5 });
237 /// It does not have an [`IntoIterator`] implementation, so you can't use it in
238 /// a `for` loop directly. This won't compile:
240 /// ```compile_fail,E0277
241 /// // error[E0277]: the trait bound `std::ops::RangeTo<{integer}>:
242 /// // std::iter::Iterator` is not satisfied
248 /// When used as a [slicing index], `RangeTo` produces a slice of all array
249 /// elements before the index indicated by `end`.
252 /// let arr = [0, 1, 2, 3];
253 /// assert_eq!(arr[ .. ], [0,1,2,3]);
254 /// assert_eq!(arr[ ..3], [0,1,2 ]); // RangeTo
255 /// assert_eq!(arr[1.. ], [ 1,2,3]);
256 /// assert_eq!(arr[1..3], [ 1,2 ]);
259 /// [`IntoIterator`]: ../iter/trait.Iterator.html
260 /// [`Iterator`]: ../iter/trait.IntoIterator.html
261 /// [slicing index]: ../slice/trait.SliceIndex.html
263 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
264 #[stable(feature = "rust1", since = "1.0.0")]
265 pub struct RangeTo<Idx> {
266 /// The upper bound of the range (exclusive).
267 #[stable(feature = "rust1", since = "1.0.0")]
271 #[stable(feature = "rust1", since = "1.0.0")]
272 impl<Idx: fmt::Debug> fmt::Debug for RangeTo<Idx> {
273 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
274 write!(fmt, "..{:?}", self.end)
278 impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
279 /// Returns `true` if `item` is contained in the range.
284 /// #![feature(range_contains)]
288 /// assert!( (..5).contains(&-1_000_000_000));
289 /// assert!( (..5).contains(&4));
290 /// assert!(!(..5).contains(&5));
292 /// assert!( (..1.0).contains(&0.5));
293 /// assert!(!(..1.0).contains(&f32::NAN));
294 /// assert!(!(..f32::NAN).contains(&0.5));
296 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
297 pub fn contains<U>(&self, item: &U) -> bool
300 U: ?Sized + PartialOrd<Idx>,
302 <Self as RangeBounds<Idx>>::contains(self, item)
306 /// An range bounded inclusively below and above (`start..=end`).
308 /// The `RangeInclusive` `start..=end` contains all values with `x >= start`
309 /// and `x <= end`. It is empty unless `start <= end`.
311 /// This iterator is [fused], but the specific values of `start` and `end` after
312 /// iteration has finished are **unspecified** other than that [`.is_empty()`]
313 /// will return `true` once no more values will be produced.
315 /// [fused]: ../iter/trait.FusedIterator.html
316 /// [`.is_empty()`]: #method.is_empty
321 /// #![feature(inclusive_range_fields)]
323 /// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 });
324 /// assert_eq!(3 + 4 + 5, (3..=5).sum());
326 /// let arr = [0, 1, 2, 3];
327 /// assert_eq!(arr[ ..=2], [0,1,2 ]);
328 /// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
330 #[doc(alias = "..=")]
331 #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
332 #[stable(feature = "inclusive_range", since = "1.26.0")]
333 pub struct RangeInclusive<Idx> {
334 /// The lower bound of the range (inclusive).
335 #[unstable(feature = "inclusive_range_fields", issue = "49022")]
337 /// The upper bound of the range (inclusive).
338 #[unstable(feature = "inclusive_range_fields", issue = "49022")]
342 #[stable(feature = "inclusive_range", since = "1.26.0")]
343 impl<Idx: fmt::Debug> fmt::Debug for RangeInclusive<Idx> {
344 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
345 write!(fmt, "{:?}..={:?}", self.start, self.end)
349 impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
350 /// Returns `true` if `item` is contained in the range.
355 /// #![feature(range_contains)]
359 /// assert!(!(3..=5).contains(&2));
360 /// assert!( (3..=5).contains(&3));
361 /// assert!( (3..=5).contains(&4));
362 /// assert!( (3..=5).contains(&5));
363 /// assert!(!(3..=5).contains(&6));
365 /// assert!( (3..=3).contains(&3));
366 /// assert!(!(3..=2).contains(&3));
368 /// assert!( (0.0..=1.0).contains(&1.0));
369 /// assert!(!(0.0..=1.0).contains(&f32::NAN));
370 /// assert!(!(0.0..=f32::NAN).contains(&0.0));
371 /// assert!(!(f32::NAN..=1.0).contains(&1.0));
373 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
374 pub fn contains<U>(&self, item: &U) -> bool
377 U: ?Sized + PartialOrd<Idx>,
379 <Self as RangeBounds<Idx>>::contains(self, item)
382 /// Returns `true` if the range contains no items.
387 /// #![feature(range_is_empty)]
389 /// assert!(!(3..=5).is_empty());
390 /// assert!(!(3..=3).is_empty());
391 /// assert!( (3..=2).is_empty());
394 /// The range is empty if either side is incomparable:
397 /// #![feature(range_is_empty)]
399 /// use std::f32::NAN;
400 /// assert!(!(3.0..=5.0).is_empty());
401 /// assert!( (3.0..=NAN).is_empty());
402 /// assert!( (NAN..=5.0).is_empty());
405 /// This method returns `true` after iteration has finished:
408 /// #![feature(range_is_empty)]
410 /// let mut r = 3..=5;
411 /// for _ in r.by_ref() {}
412 /// // Precise field values are unspecified here
413 /// assert!(r.is_empty());
415 #[unstable(feature = "range_is_empty", reason = "recently added", issue = "48111")]
416 pub fn is_empty(&self) -> bool {
417 !(self.start <= self.end)
421 /// A range only bounded inclusively above (`..=end`).
423 /// The `RangeToInclusive` `..=end` contains all values with `x <= end`.
424 /// It cannot serve as an [`Iterator`] because it doesn't have a starting point.
428 /// The `..=end` syntax is a `RangeToInclusive`:
431 /// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 });
434 /// It does not have an [`IntoIterator`] implementation, so you can't use it in a
435 /// `for` loop directly. This won't compile:
437 /// ```compile_fail,E0277
438 /// // error[E0277]: the trait bound `std::ops::RangeToInclusive<{integer}>:
439 /// // std::iter::Iterator` is not satisfied
445 /// When used as a [slicing index], `RangeToInclusive` produces a slice of all
446 /// array elements up to and including the index indicated by `end`.
449 /// let arr = [0, 1, 2, 3];
450 /// assert_eq!(arr[ ..=2], [0,1,2 ]); // RangeToInclusive
451 /// assert_eq!(arr[1..=2], [ 1,2 ]);
454 /// [`IntoIterator`]: ../iter/trait.Iterator.html
455 /// [`Iterator`]: ../iter/trait.IntoIterator.html
456 /// [slicing index]: ../slice/trait.SliceIndex.html
457 #[doc(alias = "..=")]
458 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
459 #[stable(feature = "inclusive_range", since = "1.26.0")]
460 pub struct RangeToInclusive<Idx> {
461 /// The upper bound of the range (inclusive)
462 #[stable(feature = "inclusive_range", since = "1.26.0")]
466 #[stable(feature = "inclusive_range", since = "1.26.0")]
467 impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
468 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
469 write!(fmt, "..={:?}", self.end)
473 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
474 impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
475 /// Returns `true` if `item` is contained in the range.
480 /// #![feature(range_contains)]
484 /// assert!( (..=5).contains(&-1_000_000_000));
485 /// assert!( (..=5).contains(&5));
486 /// assert!(!(..=5).contains(&6));
488 /// assert!( (..=1.0).contains(&1.0));
489 /// assert!(!(..=1.0).contains(&f32::NAN));
490 /// assert!(!(..=f32::NAN).contains(&0.5));
492 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
493 pub fn contains<U>(&self, item: &U) -> bool
496 U: ?Sized + PartialOrd<Idx>,
498 <Self as RangeBounds<Idx>>::contains(self, item)
502 // RangeToInclusive<Idx> cannot impl From<RangeTo<Idx>>
503 // because underflow would be possible with (..0).into()
505 /// An endpoint of a range of keys.
509 /// `Bound`s are range endpoints:
512 /// #![feature(collections_range)]
514 /// use std::ops::Bound::*;
515 /// use std::ops::RangeBounds;
517 /// assert_eq!((..100).start(), Unbounded);
518 /// assert_eq!((1..12).start(), Included(&1));
519 /// assert_eq!((1..12).end(), Excluded(&12));
522 /// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
523 /// Note that in most cases, it's better to use range syntax (`1..5`) instead.
526 /// use std::collections::BTreeMap;
527 /// use std::ops::Bound::{Excluded, Included, Unbounded};
529 /// let mut map = BTreeMap::new();
530 /// map.insert(3, "a");
531 /// map.insert(5, "b");
532 /// map.insert(8, "c");
534 /// for (key, value) in map.range((Excluded(3), Included(8))) {
535 /// println!("{}: {}", key, value);
538 /// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
541 /// [`BTreeMap::range`]: ../../std/collections/btree_map/struct.BTreeMap.html#method.range
542 #[stable(feature = "collections_bound", since = "1.17.0")]
543 #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
545 /// An inclusive bound.
546 #[stable(feature = "collections_bound", since = "1.17.0")]
547 Included(#[stable(feature = "collections_bound", since = "1.17.0")] T),
548 /// An exclusive bound.
549 #[stable(feature = "collections_bound", since = "1.17.0")]
550 Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
551 /// An infinite endpoint. Indicates that there is no bound in this direction.
552 #[stable(feature = "collections_bound", since = "1.17.0")]
556 #[unstable(feature = "collections_range",
557 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
559 /// `RangeBounds` is implemented by Rust's built-in range types, produced
560 /// by range syntax like `..`, `a..`, `..b` or `c..d`.
561 pub trait RangeBounds<T: ?Sized> {
562 /// Start index bound.
564 /// Returns the start value as a `Bound`.
569 /// #![feature(collections_range)]
572 /// use std::ops::Bound::*;
573 /// use std::ops::RangeBounds;
575 /// assert_eq!((..10).start(), Unbounded);
576 /// assert_eq!((3..10).start(), Included(&3));
579 fn start(&self) -> Bound<&T>;
583 /// Returns the end value as a `Bound`.
588 /// #![feature(collections_range)]
591 /// use std::ops::Bound::*;
592 /// use std::ops::RangeBounds;
594 /// assert_eq!((3..).end(), Unbounded);
595 /// assert_eq!((3..10).end(), Excluded(&10));
598 fn end(&self) -> Bound<&T>;
601 /// Returns `true` if `item` is contained in the range.
606 /// #![feature(range_contains)]
610 /// assert!( (3..5).contains(&4));
611 /// assert!(!(3..5).contains(&2));
613 /// assert!( (0.0..1.0).contains(&0.5));
614 /// assert!(!(0.0..1.0).contains(&f32::NAN));
615 /// assert!(!(0.0..f32::NAN).contains(&0.5));
616 /// assert!(!(f32::NAN..1.0).contains(&0.5));
617 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
618 fn contains<U>(&self, item: &U) -> bool
621 U: ?Sized + PartialOrd<T>,
623 (match self.start() {
624 Included(ref start) => *start <= item,
625 Excluded(ref start) => *start < item,
630 Included(ref end) => item <= *end,
631 Excluded(ref end) => item < *end,
637 use self::Bound::{Excluded, Included, Unbounded};
639 #[unstable(feature = "collections_range",
640 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
642 impl<T: ?Sized> RangeBounds<T> for RangeFull {
643 fn start(&self) -> Bound<&T> {
646 fn end(&self) -> Bound<&T> {
651 #[unstable(feature = "collections_range",
652 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
654 impl<T> RangeBounds<T> for RangeFrom<T> {
655 fn start(&self) -> Bound<&T> {
656 Included(&self.start)
658 fn end(&self) -> Bound<&T> {
663 #[unstable(feature = "collections_range",
664 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
666 impl<T> RangeBounds<T> for RangeTo<T> {
667 fn start(&self) -> Bound<&T> {
670 fn end(&self) -> Bound<&T> {
675 #[unstable(feature = "collections_range",
676 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
678 impl<T> RangeBounds<T> for Range<T> {
679 fn start(&self) -> Bound<&T> {
680 Included(&self.start)
682 fn end(&self) -> Bound<&T> {
687 #[unstable(feature = "collections_range",
688 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
690 impl<T> RangeBounds<T> for RangeInclusive<T> {
691 fn start(&self) -> Bound<&T> {
692 Included(&self.start)
694 fn end(&self) -> Bound<&T> {
699 #[unstable(feature = "collections_range",
700 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
702 impl<T> RangeBounds<T> for RangeToInclusive<T> {
703 fn start(&self) -> Bound<&T> {
706 fn end(&self) -> Bound<&T> {
711 #[unstable(feature = "collections_range",
712 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
714 impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
715 fn start(&self) -> Bound<&T> {
717 (Included(ref start), _) => Included(start),
718 (Excluded(ref start), _) => Excluded(start),
719 (Unbounded, _) => Unbounded,
723 fn end(&self) -> Bound<&T> {
725 (_, Included(ref end)) => Included(end),
726 (_, Excluded(ref end)) => Excluded(end),
727 (_, Unbounded) => Unbounded,
732 #[unstable(feature = "collections_range",
733 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
735 impl<'a, T: ?Sized + 'a> RangeBounds<T> for (Bound<&'a T>, Bound<&'a T>) {
736 fn start(&self) -> Bound<&T> {
740 fn end(&self) -> Bound<&T> {
745 #[unstable(feature = "collections_range",
746 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
748 impl<'a, T> RangeBounds<T> for RangeFrom<&'a T> {
749 fn start(&self) -> Bound<&T> {
752 fn end(&self) -> Bound<&T> {
757 #[unstable(feature = "collections_range",
758 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
760 impl<'a, T> RangeBounds<T> for RangeTo<&'a T> {
761 fn start(&self) -> Bound<&T> {
764 fn end(&self) -> Bound<&T> {
769 #[unstable(feature = "collections_range",
770 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
772 impl<'a, T> RangeBounds<T> for Range<&'a T> {
773 fn start(&self) -> Bound<&T> {
776 fn end(&self) -> Bound<&T> {
781 #[unstable(feature = "collections_range",
782 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
784 impl<'a, T> RangeBounds<T> for RangeInclusive<&'a T> {
785 fn start(&self) -> Bound<&T> {
788 fn end(&self) -> Bound<&T> {
793 #[unstable(feature = "collections_range",
794 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
796 impl<'a, T> RangeBounds<T> for RangeToInclusive<&'a T> {
797 fn start(&self) -> Bound<&T> {
800 fn end(&self) -> Bound<&T> {