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
48 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
49 #[stable(feature = "rust1", since = "1.0.0")]
52 #[stable(feature = "rust1", since = "1.0.0")]
53 impl fmt::Debug for RangeFull {
54 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
59 /// A (half-open) range bounded inclusively below and exclusively above
62 /// The `Range` `start..end` contains all values with `x >= start` and
63 /// `x < end`. It is empty unless `start < end`.
68 /// assert_eq!((3..5), std::ops::Range { start: 3, end: 5 });
69 /// assert_eq!(3 + 4 + 5, (3..6).sum());
71 /// let arr = ['a', 'b', 'c', 'd'];
72 /// assert_eq!(arr[ .. ], ['a', 'b', 'c', 'd']);
73 /// assert_eq!(arr[ ..3], ['a', 'b', 'c', ]);
74 /// assert_eq!(arr[1.. ], [ 'b', 'c', 'd']);
75 /// assert_eq!(arr[1..3], [ 'b', 'c' ]); // Range
77 #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
78 #[stable(feature = "rust1", since = "1.0.0")]
79 pub struct Range<Idx> {
80 /// The lower bound of the range (inclusive).
81 #[stable(feature = "rust1", since = "1.0.0")]
83 /// The upper bound of the range (exclusive).
84 #[stable(feature = "rust1", since = "1.0.0")]
88 #[stable(feature = "rust1", since = "1.0.0")]
89 impl<Idx: fmt::Debug> fmt::Debug for Range<Idx> {
90 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
91 write!(fmt, "{:?}..{:?}", self.start, self.end)
95 impl<Idx: PartialOrd<Idx>> Range<Idx> {
96 /// Returns `true` if `item` is contained in the range.
101 /// #![feature(range_contains)]
105 /// assert!(!(3..5).contains(&2));
106 /// assert!( (3..5).contains(&3));
107 /// assert!( (3..5).contains(&4));
108 /// assert!(!(3..5).contains(&5));
110 /// assert!(!(3..3).contains(&3));
111 /// assert!(!(3..2).contains(&3));
113 /// assert!( (0.0..1.0).contains(&0.5));
114 /// assert!(!(0.0..1.0).contains(&f32::NAN));
115 /// assert!(!(0.0..f32::NAN).contains(&0.5));
116 /// assert!(!(f32::NAN..1.0).contains(&0.5));
118 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
119 pub fn contains<U>(&self, item: &U) -> bool
122 U: ?Sized + PartialOrd<Idx>,
124 <Self as RangeBounds<Idx>>::contains(self, item)
127 /// Returns `true` if the range contains no items.
132 /// #![feature(range_is_empty)]
134 /// assert!(!(3..5).is_empty());
135 /// assert!( (3..3).is_empty());
136 /// assert!( (3..2).is_empty());
139 /// The range is empty if either side is incomparable:
142 /// #![feature(range_is_empty)]
144 /// use std::f32::NAN;
145 /// assert!(!(3.0..5.0).is_empty());
146 /// assert!( (3.0..NAN).is_empty());
147 /// assert!( (NAN..5.0).is_empty());
149 #[unstable(feature = "range_is_empty", reason = "recently added", issue = "48111")]
150 pub fn is_empty(&self) -> bool {
151 !(self.start < self.end)
155 /// A range only bounded inclusively below (`start..`).
157 /// The `RangeFrom` `start..` contains all values with `x >= start`.
159 /// *Note*: Currently, no overflow checking is done for the [`Iterator`]
160 /// implementation; if you use an integer range and the integer overflows, it
161 /// might panic in debug mode or create an endless loop in release mode. **This
162 /// overflow behavior might change in the future.**
167 /// assert_eq!((2..), std::ops::RangeFrom { start: 2 });
168 /// assert_eq!(2 + 3 + 4, (2..).take(3).sum());
170 /// let arr = [0, 1, 2, 3];
171 /// assert_eq!(arr[ .. ], [0,1,2,3]);
172 /// assert_eq!(arr[ ..3], [0,1,2 ]);
173 /// assert_eq!(arr[1.. ], [ 1,2,3]); // RangeFrom
174 /// assert_eq!(arr[1..3], [ 1,2 ]);
177 /// [`Iterator`]: ../iter/trait.IntoIterator.html
178 #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
179 #[stable(feature = "rust1", since = "1.0.0")]
180 pub struct RangeFrom<Idx> {
181 /// The lower bound of the range (inclusive).
182 #[stable(feature = "rust1", since = "1.0.0")]
186 #[stable(feature = "rust1", since = "1.0.0")]
187 impl<Idx: fmt::Debug> fmt::Debug for RangeFrom<Idx> {
188 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
189 write!(fmt, "{:?}..", self.start)
193 impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
194 /// Returns `true` if `item` is contained in the range.
199 /// #![feature(range_contains)]
203 /// assert!(!(3..).contains(&2));
204 /// assert!( (3..).contains(&3));
205 /// assert!( (3..).contains(&1_000_000_000));
207 /// assert!( (0.0..).contains(&0.5));
208 /// assert!(!(0.0..).contains(&f32::NAN));
209 /// assert!(!(f32::NAN..).contains(&0.5));
211 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
212 pub fn contains<U>(&self, item: &U) -> bool
215 U: ?Sized + PartialOrd<Idx>,
217 <Self as RangeBounds<Idx>>::contains(self, item)
221 /// A range only bounded exclusively above (`..end`).
223 /// The `RangeTo` `..end` contains all values with `x < end`.
224 /// It cannot serve as an [`Iterator`] because it doesn't have a starting point.
228 /// The `..end` syntax is a `RangeTo`:
231 /// assert_eq!((..5), std::ops::RangeTo { end: 5 });
234 /// It does not have an [`IntoIterator`] implementation, so you can't use it in
235 /// a `for` loop directly. This won't compile:
237 /// ```compile_fail,E0277
238 /// // error[E0277]: the trait bound `std::ops::RangeTo<{integer}>:
239 /// // std::iter::Iterator` is not satisfied
245 /// When used as a [slicing index], `RangeTo` produces a slice of all array
246 /// elements before the index indicated by `end`.
249 /// let arr = [0, 1, 2, 3];
250 /// assert_eq!(arr[ .. ], [0,1,2,3]);
251 /// assert_eq!(arr[ ..3], [0,1,2 ]); // RangeTo
252 /// assert_eq!(arr[1.. ], [ 1,2,3]);
253 /// assert_eq!(arr[1..3], [ 1,2 ]);
256 /// [`IntoIterator`]: ../iter/trait.Iterator.html
257 /// [`Iterator`]: ../iter/trait.IntoIterator.html
258 /// [slicing index]: ../slice/trait.SliceIndex.html
259 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
260 #[stable(feature = "rust1", since = "1.0.0")]
261 pub struct RangeTo<Idx> {
262 /// The upper bound of the range (exclusive).
263 #[stable(feature = "rust1", since = "1.0.0")]
267 #[stable(feature = "rust1", since = "1.0.0")]
268 impl<Idx: fmt::Debug> fmt::Debug for RangeTo<Idx> {
269 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
270 write!(fmt, "..{:?}", self.end)
274 impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
275 /// Returns `true` if `item` is contained in the range.
280 /// #![feature(range_contains)]
284 /// assert!( (..5).contains(&-1_000_000_000));
285 /// assert!( (..5).contains(&4));
286 /// assert!(!(..5).contains(&5));
288 /// assert!( (..1.0).contains(&0.5));
289 /// assert!(!(..1.0).contains(&f32::NAN));
290 /// assert!(!(..f32::NAN).contains(&0.5));
292 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
293 pub fn contains<U>(&self, item: &U) -> bool
296 U: ?Sized + PartialOrd<Idx>,
298 <Self as RangeBounds<Idx>>::contains(self, item)
302 /// An range bounded inclusively below and above (`start..=end`).
304 /// The `RangeInclusive` `start..=end` contains all values with `x >= start`
305 /// and `x <= end`. It is empty unless `start <= end`.
307 /// This iterator is [fused], but the specific values of `start` and `end` after
308 /// iteration has finished are **unspecified** other than that [`.is_empty()`]
309 /// will return `true` once no more values will be produced.
311 /// [fused]: ../iter/trait.FusedIterator.html
312 /// [`.is_empty()`]: #method.is_empty
317 /// #![feature(inclusive_range_fields)]
319 /// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 });
320 /// assert_eq!(3 + 4 + 5, (3..=5).sum());
322 /// let arr = [0, 1, 2, 3];
323 /// assert_eq!(arr[ ..=2], [0,1,2 ]);
324 /// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
326 #[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
327 #[stable(feature = "inclusive_range", since = "1.26.0")]
328 pub struct RangeInclusive<Idx> {
329 /// The lower bound of the range (inclusive).
330 #[unstable(feature = "inclusive_range_fields", issue = "49022")]
332 /// The upper bound of the range (inclusive).
333 #[unstable(feature = "inclusive_range_fields", issue = "49022")]
337 #[stable(feature = "inclusive_range", since = "1.26.0")]
338 impl<Idx: fmt::Debug> fmt::Debug for RangeInclusive<Idx> {
339 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
340 write!(fmt, "{:?}..={:?}", self.start, self.end)
344 impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
345 /// Returns `true` if `item` is contained in the range.
350 /// #![feature(range_contains)]
354 /// assert!(!(3..=5).contains(&2));
355 /// assert!( (3..=5).contains(&3));
356 /// assert!( (3..=5).contains(&4));
357 /// assert!( (3..=5).contains(&5));
358 /// assert!(!(3..=5).contains(&6));
360 /// assert!( (3..=3).contains(&3));
361 /// assert!(!(3..=2).contains(&3));
363 /// assert!( (0.0..=1.0).contains(&1.0));
364 /// assert!(!(0.0..=1.0).contains(&f32::NAN));
365 /// assert!(!(0.0..=f32::NAN).contains(&0.0));
366 /// assert!(!(f32::NAN..=1.0).contains(&1.0));
368 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
369 pub fn contains<U>(&self, item: &U) -> bool
372 U: ?Sized + PartialOrd<Idx>,
374 <Self as RangeBounds<Idx>>::contains(self, item)
377 /// Returns `true` if the range contains no items.
382 /// #![feature(range_is_empty)]
384 /// assert!(!(3..=5).is_empty());
385 /// assert!(!(3..=3).is_empty());
386 /// assert!( (3..=2).is_empty());
389 /// The range is empty if either side is incomparable:
392 /// #![feature(range_is_empty)]
394 /// use std::f32::NAN;
395 /// assert!(!(3.0..=5.0).is_empty());
396 /// assert!( (3.0..=NAN).is_empty());
397 /// assert!( (NAN..=5.0).is_empty());
400 /// This method returns `true` after iteration has finished:
403 /// #![feature(range_is_empty)]
405 /// let mut r = 3..=5;
406 /// for _ in r.by_ref() {}
407 /// // Precise field values are unspecified here
408 /// assert!(r.is_empty());
410 #[unstable(feature = "range_is_empty", reason = "recently added", issue = "48111")]
411 pub fn is_empty(&self) -> bool {
412 !(self.start <= self.end)
416 /// A range only bounded inclusively above (`..=end`).
418 /// The `RangeToInclusive` `..=end` contains all values with `x <= end`.
419 /// It cannot serve as an [`Iterator`] because it doesn't have a starting point.
423 /// The `..=end` syntax is a `RangeToInclusive`:
426 /// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 });
429 /// It does not have an [`IntoIterator`] implementation, so you can't use it in a
430 /// `for` loop directly. This won't compile:
432 /// ```compile_fail,E0277
433 /// // error[E0277]: the trait bound `std::ops::RangeToInclusive<{integer}>:
434 /// // std::iter::Iterator` is not satisfied
440 /// When used as a [slicing index], `RangeToInclusive` produces a slice of all
441 /// array elements up to and including the index indicated by `end`.
444 /// let arr = [0, 1, 2, 3];
445 /// assert_eq!(arr[ ..=2], [0,1,2 ]); // RangeToInclusive
446 /// assert_eq!(arr[1..=2], [ 1,2 ]);
449 /// [`IntoIterator`]: ../iter/trait.Iterator.html
450 /// [`Iterator`]: ../iter/trait.IntoIterator.html
451 /// [slicing index]: ../slice/trait.SliceIndex.html
452 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
453 #[stable(feature = "inclusive_range", since = "1.26.0")]
454 pub struct RangeToInclusive<Idx> {
455 /// The upper bound of the range (inclusive)
456 #[stable(feature = "inclusive_range", since = "1.26.0")]
460 #[stable(feature = "inclusive_range", since = "1.26.0")]
461 impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
462 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
463 write!(fmt, "..={:?}", self.end)
467 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
468 impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
469 /// Returns `true` if `item` is contained in the range.
474 /// #![feature(range_contains)]
478 /// assert!( (..=5).contains(&-1_000_000_000));
479 /// assert!( (..=5).contains(&5));
480 /// assert!(!(..=5).contains(&6));
482 /// assert!( (..=1.0).contains(&1.0));
483 /// assert!(!(..=1.0).contains(&f32::NAN));
484 /// assert!(!(..=f32::NAN).contains(&0.5));
486 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
487 pub fn contains<U>(&self, item: &U) -> bool
490 U: ?Sized + PartialOrd<Idx>,
492 <Self as RangeBounds<Idx>>::contains(self, item)
496 // RangeToInclusive<Idx> cannot impl From<RangeTo<Idx>>
497 // because underflow would be possible with (..0).into()
499 /// An endpoint of a range of keys.
503 /// `Bound`s are range endpoints:
506 /// #![feature(collections_range)]
508 /// use std::ops::Bound::*;
509 /// use std::ops::RangeBounds;
511 /// assert_eq!((..100).start(), Unbounded);
512 /// assert_eq!((1..12).start(), Included(&1));
513 /// assert_eq!((1..12).end(), Excluded(&12));
516 /// Using a tuple of `Bound`s as an argument to [`BTreeMap::range`].
517 /// Note that in most cases, it's better to use range syntax (`1..5`) instead.
520 /// use std::collections::BTreeMap;
521 /// use std::ops::Bound::{Excluded, Included, Unbounded};
523 /// let mut map = BTreeMap::new();
524 /// map.insert(3, "a");
525 /// map.insert(5, "b");
526 /// map.insert(8, "c");
528 /// for (key, value) in map.range((Excluded(3), Included(8))) {
529 /// println!("{}: {}", key, value);
532 /// assert_eq!(Some((&3, &"a")), map.range((Unbounded, Included(5))).next());
535 /// [`BTreeMap::range`]: ../../std/collections/btree_map/struct.BTreeMap.html#method.range
536 #[stable(feature = "collections_bound", since = "1.17.0")]
537 #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
539 /// An inclusive bound.
540 #[stable(feature = "collections_bound", since = "1.17.0")]
541 Included(#[stable(feature = "collections_bound", since = "1.17.0")] T),
542 /// An exclusive bound.
543 #[stable(feature = "collections_bound", since = "1.17.0")]
544 Excluded(#[stable(feature = "collections_bound", since = "1.17.0")] T),
545 /// An infinite endpoint. Indicates that there is no bound in this direction.
546 #[stable(feature = "collections_bound", since = "1.17.0")]
550 #[unstable(feature = "collections_range",
551 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
553 /// `RangeBounds` is implemented by Rust's built-in range types, produced
554 /// by range syntax like `..`, `a..`, `..b` or `c..d`.
555 pub trait RangeBounds<T: ?Sized> {
556 /// Start index bound.
558 /// Returns the start value as a `Bound`.
563 /// #![feature(collections_range)]
566 /// use std::ops::Bound::*;
567 /// use std::ops::RangeBounds;
569 /// assert_eq!((..10).start(), Unbounded);
570 /// assert_eq!((3..10).start(), Included(&3));
573 fn start(&self) -> Bound<&T>;
577 /// Returns the end value as a `Bound`.
582 /// #![feature(collections_range)]
585 /// use std::ops::Bound::*;
586 /// use std::ops::RangeBounds;
588 /// assert_eq!((3..).end(), Unbounded);
589 /// assert_eq!((3..10).end(), Excluded(&10));
592 fn end(&self) -> Bound<&T>;
595 /// Returns `true` if `item` is contained in the range.
600 /// #![feature(range_contains)]
604 /// assert!( (3..5).contains(&4));
605 /// assert!(!(3..5).contains(&2));
607 /// assert!( (0.0..1.0).contains(&0.5));
608 /// assert!(!(0.0..1.0).contains(&f32::NAN));
609 /// assert!(!(0.0..f32::NAN).contains(&0.5));
610 /// assert!(!(f32::NAN..1.0).contains(&0.5));
611 #[unstable(feature = "range_contains", reason = "recently added as per RFC", issue = "32311")]
612 fn contains<U>(&self, item: &U) -> bool
615 U: ?Sized + PartialOrd<T>,
617 (match self.start() {
618 Included(ref start) => *start <= item,
619 Excluded(ref start) => *start < item,
624 Included(ref end) => item <= *end,
625 Excluded(ref end) => item < *end,
631 use self::Bound::{Excluded, Included, Unbounded};
633 #[unstable(feature = "collections_range",
634 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
636 impl<T: ?Sized> RangeBounds<T> for RangeFull {
637 fn start(&self) -> Bound<&T> {
640 fn end(&self) -> Bound<&T> {
645 #[unstable(feature = "collections_range",
646 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
648 impl<T> RangeBounds<T> for RangeFrom<T> {
649 fn start(&self) -> Bound<&T> {
650 Included(&self.start)
652 fn end(&self) -> Bound<&T> {
657 #[unstable(feature = "collections_range",
658 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
660 impl<T> RangeBounds<T> for RangeTo<T> {
661 fn start(&self) -> Bound<&T> {
664 fn end(&self) -> Bound<&T> {
669 #[unstable(feature = "collections_range",
670 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
672 impl<T> RangeBounds<T> for Range<T> {
673 fn start(&self) -> Bound<&T> {
674 Included(&self.start)
676 fn end(&self) -> Bound<&T> {
681 #[unstable(feature = "collections_range",
682 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
684 impl<T> RangeBounds<T> for RangeInclusive<T> {
685 fn start(&self) -> Bound<&T> {
686 Included(&self.start)
688 fn end(&self) -> Bound<&T> {
693 #[unstable(feature = "collections_range",
694 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
696 impl<T> RangeBounds<T> for RangeToInclusive<T> {
697 fn start(&self) -> Bound<&T> {
700 fn end(&self) -> Bound<&T> {
705 #[unstable(feature = "collections_range",
706 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
708 impl<T> RangeBounds<T> for (Bound<T>, Bound<T>) {
709 fn start(&self) -> Bound<&T> {
711 (Included(ref start), _) => Included(start),
712 (Excluded(ref start), _) => Excluded(start),
713 (Unbounded, _) => Unbounded,
717 fn end(&self) -> Bound<&T> {
719 (_, Included(ref end)) => Included(end),
720 (_, Excluded(ref end)) => Excluded(end),
721 (_, Unbounded) => Unbounded,
726 #[unstable(feature = "collections_range",
727 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
729 impl<'a, T: ?Sized + 'a> RangeBounds<T> for (Bound<&'a T>, Bound<&'a T>) {
730 fn start(&self) -> Bound<&T> {
734 fn end(&self) -> Bound<&T> {
739 #[unstable(feature = "collections_range",
740 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
742 impl<'a, T> RangeBounds<T> for RangeFrom<&'a T> {
743 fn start(&self) -> Bound<&T> {
746 fn end(&self) -> Bound<&T> {
751 #[unstable(feature = "collections_range",
752 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
754 impl<'a, T> RangeBounds<T> for RangeTo<&'a T> {
755 fn start(&self) -> Bound<&T> {
758 fn end(&self) -> Bound<&T> {
763 #[unstable(feature = "collections_range",
764 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
766 impl<'a, T> RangeBounds<T> for Range<&'a T> {
767 fn start(&self) -> Bound<&T> {
770 fn end(&self) -> Bound<&T> {
775 #[unstable(feature = "collections_range",
776 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
778 impl<'a, T> RangeBounds<T> for RangeInclusive<&'a T> {
779 fn start(&self) -> Bound<&T> {
782 fn end(&self) -> Bound<&T> {
787 #[unstable(feature = "collections_range",
788 reason = "might be replaced with `Into<_>` and a type containing two `Bound` values",
790 impl<'a, T> RangeBounds<T> for RangeToInclusive<&'a T> {
791 fn start(&self) -> Bound<&T> {
794 fn end(&self) -> Bound<&T> {