pub struct RangeInclusive<Idx> {
pub start: Idx,
pub last: Idx,
}
new_range_api #125687)
A range bounded inclusively below and above (start..=last).
The RangeInclusive start..=last contains all values with x >= start and x <= last. It is empty unless start <= last.
The start..=last syntax is a RangeInclusive:
#![feature(new_range_api)]
use core::range::RangeInclusive;
assert_eq!(RangeInclusive::from(3..=5), RangeInclusive { start: 3, last: 5 });
assert_eq!(3 + 4 + 5, RangeInclusive::from(3..=5).into_iter().sum());start: Idxnew_range_api #125687)
The lower bound of the range (inclusive).
last: Idxnew_range_api #125687)
The upper bound of the range (inclusive).
impl<Idx> RangeInclusive<Idx>where
Idx: PartialOrd,pub const fn contains<U>(&self, item: &U) -> boolwhere
Idx: PartialOrd<U>,
U: PartialOrd<Idx> + ?Sized,new_range_api #125687)
Returns true if item is contained in the range.
#![feature(new_range_api)] use core::range::RangeInclusive; assert!(!RangeInclusive::from(3..=5).contains(&2)); assert!( RangeInclusive::from(3..=5).contains(&3)); assert!( RangeInclusive::from(3..=5).contains(&4)); assert!( RangeInclusive::from(3..=5).contains(&5)); assert!(!RangeInclusive::from(3..=5).contains(&6)); assert!( RangeInclusive::from(3..=3).contains(&3)); assert!(!RangeInclusive::from(3..=2).contains(&3)); assert!( RangeInclusive::from(0.0..=1.0).contains(&1.0)); assert!(!RangeInclusive::from(0.0..=1.0).contains(&f32::NAN)); assert!(!RangeInclusive::from(0.0..=f32::NAN).contains(&0.0)); assert!(!RangeInclusive::from(f32::NAN..=1.0).contains(&1.0));
pub const fn is_empty(&self) -> boolwhere
Idx: PartialOrd,new_range_api #125687)
Returns true if the range contains no items.
#![feature(new_range_api)] use core::range::RangeInclusive; assert!(!RangeInclusive::from(3..=5).is_empty()); assert!(!RangeInclusive::from(3..=3).is_empty()); assert!( RangeInclusive::from(3..=2).is_empty());
The range is empty if either side is incomparable:
#![feature(new_range_api)] use core::range::RangeInclusive; assert!(!RangeInclusive::from(3.0..=5.0).is_empty()); assert!( RangeInclusive::from(3.0..=f32::NAN).is_empty()); assert!( RangeInclusive::from(f32::NAN..=5.0).is_empty());
impl<Idx> RangeInclusive<Idx>where
Idx: Step,pub fn iter(&self) -> RangeInclusiveIter<Idx> ⓘ
new_range_api #125687)
Creates an iterator over the elements within this range.
Shorthand for .clone().into_iter()
#![feature(new_range_api)] use core::range::RangeInclusive; let mut i = RangeInclusive::from(3..=8).iter().map(|n| n*n); assert_eq!(i.next(), Some(9)); assert_eq!(i.next(), Some(16)); assert_eq!(i.next(), Some(25));
impl<Idx> Clone for RangeInclusive<Idx>where
Idx: Clone,fn clone(&self) -> RangeInclusive<Idx>
fn clone_from(&mut self, source: &Self)
source. Read more
impl<Idx> Debug for RangeInclusive<Idx>where
Idx: Debug,fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>
impl<T> From<RangeInclusive<T>> for RangeInclusive<T>
fn from(value: RangeInclusive<T>) -> RangeInclusive<T> ⓘ
impl<T> From<RangeInclusive<T>> for RangeInclusive<T>
fn from(value: RangeInclusive<T>) -> RangeInclusive<T>
impl GetDisjointMutIndex for RangeInclusive<usize>
fn is_in_bounds(&self, len: usize) -> bool
get_disjoint_mut_helpers)
true if self is in bounds for len slice elements.fn is_overlapping(&self, other: &RangeInclusive<usize>) -> bool
get_disjoint_mut_helpers)
impl<Idx> Hash for RangeInclusive<Idx>where
Idx: Hash,fn hash<__H>(&self, state: &mut __H)where
__H: Hasher,fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
Self: Sized,impl<T> IntoBounds<T> for RangeInclusive<T>
fn into_bounds(self) -> (Bound<T>, Bound<T>)
range_into_bounds #136903)
(start_bound, end_bound). Read more
fn intersect<R>(self, other: R) -> (Bound<T>, Bound<T>)where
Self: Sized,
T: Ord,
R: IntoBounds<T>,range_into_bounds #136903)
impl<A> IntoIterator for RangeInclusive<A>where
A: Step,type Item = A
type IntoIter = RangeInclusiveIter<A>
fn into_iter(self) -> <RangeInclusive<A> as IntoIterator>::IntoIter
impl<Idx> PartialEq for RangeInclusive<Idx>where
Idx: PartialEq,fn eq(&self, other: &RangeInclusive<Idx>) -> bool
self and other values to be equal, and is used by ==.fn ne(&self, other: &Rhs) -> bool
!=. The default implementation is almost always sufficient, and should not be overridden without very good reason.impl<T> RangeBounds<T> for RangeInclusive<&T>If you need to use this implementation where T is unsized, consider using the RangeBounds impl for a 2-tuple of Bound<&T>, i.e. replace start..=end with (Bound::Included(start), Bound::Included(end)).
fn start_bound(&self) -> Bound<&T>
fn end_bound(&self) -> Bound<&T>
fn contains<U>(&self, item: &U) -> boolwhere
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,fn is_empty(&self) -> boolwhere
T: PartialOrd,range_bounds_is_empty #137300)
true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. Read more
impl<T> RangeBounds<T> for RangeInclusive<T>
fn start_bound(&self) -> Bound<&T>
fn end_bound(&self) -> Bound<&T>
fn contains<U>(&self, item: &U) -> boolwhere
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,fn is_empty(&self) -> boolwhere
T: PartialOrd,range_bounds_is_empty #137300)
true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. Read more
impl<T> SliceIndex<[T]> for RangeInclusive<usize>
type Output = [T]
fn get(self, slice: &[T]) -> Option<&[T]>
slice_index_methods)
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
slice_index_methods)
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
slice_index_methods)
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
slice_index_methods)
fn index(self, slice: &[T]) -> &[T]
slice_index_methods)
fn index_mut(self, slice: &mut [T]) -> &mut [T]
slice_index_methods)
impl SliceIndex<ByteStr> for RangeInclusive<usize>
type Output = ByteStr
fn get(
self,
slice: &ByteStr,
) -> Option<&<RangeInclusive<usize> as SliceIndex<ByteStr>>::Output>slice_index_methods)
fn get_mut(
self,
slice: &mut ByteStr,
) -> Option<&mut <RangeInclusive<usize> as SliceIndex<ByteStr>>::Output>slice_index_methods)
unsafe fn get_unchecked(
self,
slice: *const ByteStr,
) -> *const <RangeInclusive<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
unsafe fn get_unchecked_mut(
self,
slice: *mut ByteStr,
) -> *mut <RangeInclusive<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
fn index(
self,
slice: &ByteStr,
) -> &<RangeInclusive<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
fn index_mut(
self,
slice: &mut ByteStr,
) -> &mut <RangeInclusive<usize> as SliceIndex<ByteStr>>::Outputslice_index_methods)
impl SliceIndex<str> for RangeInclusive<usize>
type Output = str
fn get(
self,
slice: &str,
) -> Option<&<RangeInclusive<usize> as SliceIndex<str>>::Output>slice_index_methods)
fn get_mut(
self,
slice: &mut str,
) -> Option<&mut <RangeInclusive<usize> as SliceIndex<str>>::Output>slice_index_methods)
unsafe fn get_unchecked(
self,
slice: *const str,
) -> *const <RangeInclusive<usize> as SliceIndex<str>>::Outputslice_index_methods)
unsafe fn get_unchecked_mut(
self,
slice: *mut str,
) -> *mut <RangeInclusive<usize> as SliceIndex<str>>::Outputslice_index_methods)
fn index(
self,
slice: &str,
) -> &<RangeInclusive<usize> as SliceIndex<str>>::Outputslice_index_methods)
fn index_mut(
self,
slice: &mut str,
) -> &mut <RangeInclusive<usize> as SliceIndex<str>>::Outputslice_index_methods)
impl<Idx> Copy for RangeInclusive<Idx>where
Idx: Copy,impl<Idx> Eq for RangeInclusive<Idx>where
Idx: Eq,impl<Idx> StructuralPartialEq for RangeInclusive<Idx>
impl<Idx> Freeze for RangeInclusive<Idx>where
Idx: Freeze,impl<Idx> RefUnwindSafe for RangeInclusive<Idx>where
Idx: RefUnwindSafe,impl<Idx> Send for RangeInclusive<Idx>where
Idx: Send,impl<Idx> Sync for RangeInclusive<Idx>where
Idx: Sync,impl<Idx> Unpin for RangeInclusive<Idx>where
Idx: Unpin,impl<Idx> UnwindSafe for RangeInclusive<Idx>where
Idx: UnwindSafe,impl<T> Any for Twhere
T: 'static + ?Sized,impl<T> Borrow<T> for Twhere
T: ?Sized,impl<T> BorrowMut<T> for Twhere
T: ?Sized,impl<T> CloneToUninit for Twhere
T: Clone,unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit #126799)
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for Twhere
U: From<T>,fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
impl<T> ToOwned for Twhere
T: Clone,type Owned = T
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/range/struct.RangeInclusive.html