pub struct Range<Idx> {
pub start: Idx,
pub end: Idx,
}๐ฌThis is a nightly-only experimental API. (
new_range_api)Expand description
A (half-open) range bounded inclusively below and exclusively above
(start..end in a future edition).
The range start..end contains all values with start <= x < end.
It is empty if start >= end.
ยงExamples
#![feature(new_range_api)]
use core::range::Range;
assert_eq!(Range::from(3..5), Range { start: 3, end: 5 });
assert_eq!(3 + 4 + 5, Range::from(3..6).into_iter().sum());Fieldsยง
ยงstart: Idx๐ฌThis is a nightly-only experimental API. (
new_range_api)The lower bound of the range (inclusive).
end: Idx๐ฌThis is a nightly-only experimental API. (
new_range_api)The upper bound of the range (exclusive).
Implementationsยง
Sourceยงimpl<Idx> Range<Idx>where
Idx: Step,
impl<Idx> Range<Idx>where
Idx: Step,
Sourcepub fn iter(&self) -> RangeIter<Idx> โ
๐ฌThis is a nightly-only experimental API. (new_range_api)
pub fn iter(&self) -> RangeIter<Idx> โ
new_range_api)Creates an iterator over the elements within this range.
Shorthand for .clone().into_iter()
ยงExamples
#![feature(new_range_api)]
use core::range::Range;
let mut i = Range::from(3..9).iter().map(|n| n*n);
assert_eq!(i.next(), Some(9));
assert_eq!(i.next(), Some(16));
assert_eq!(i.next(), Some(25));Sourceยงimpl<Idx> Range<Idx>where
Idx: PartialOrd,
impl<Idx> Range<Idx>where
Idx: PartialOrd,
Sourcepub const fn contains<U>(&self, item: &U) -> bool
๐ฌThis is a nightly-only experimental API. (new_range_api)
pub const fn contains<U>(&self, item: &U) -> bool
new_range_api)Returns true if item is contained in the range.
ยงExamples
#![feature(new_range_api)]
use core::range::Range;
assert!(!Range::from(3..5).contains(&2));
assert!( Range::from(3..5).contains(&3));
assert!( Range::from(3..5).contains(&4));
assert!(!Range::from(3..5).contains(&5));
assert!(!Range::from(3..3).contains(&3));
assert!(!Range::from(3..2).contains(&3));
assert!( Range::from(0.0..1.0).contains(&0.5));
assert!(!Range::from(0.0..1.0).contains(&f32::NAN));
assert!(!Range::from(0.0..f32::NAN).contains(&0.5));
assert!(!Range::from(f32::NAN..1.0).contains(&0.5));Sourcepub const fn is_empty(&self) -> boolwhere
Idx: PartialOrd,
๐ฌThis is a nightly-only experimental API. (new_range_api)
pub const fn is_empty(&self) -> boolwhere
Idx: PartialOrd,
new_range_api)Returns true if the range contains no items.
ยงExamples
#![feature(new_range_api)]
use core::range::Range;
assert!(!Range::from(3..5).is_empty());
assert!( Range::from(3..3).is_empty());
assert!( Range::from(3..2).is_empty());The range is empty if either side is incomparable:
#![feature(new_range_api)]
use core::range::Range;
assert!(!Range::from(3.0..5.0).is_empty());
assert!( Range::from(3.0..f32::NAN).is_empty());
assert!( Range::from(f32::NAN..5.0).is_empty());Trait Implementationsยง
Sourceยงimpl GetDisjointMutIndex for Range<usize>
impl GetDisjointMutIndex for Range<usize>
Sourceยงfn is_in_bounds(&self, len: usize) -> bool
fn is_in_bounds(&self, len: usize) -> bool
๐ฌThis is a nightly-only experimental API. (
get_disjoint_mut_helpers)Returns
true if self is in bounds for len slice elements.Sourceยงimpl<T> IntoBounds<T> for Range<T>
impl<T> IntoBounds<T> for Range<T>
Sourceยงimpl<A> IntoIterator for Range<A>where
A: Step,
impl<A> IntoIterator for Range<A>where
A: Step,
Sourceยงimpl<T> RangeBounds<T> for Range<&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::Excluded(end)).
impl<T> RangeBounds<T> for Range<&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::Excluded(end)).
Sourceยงimpl<T> RangeBounds<T> for Range<T>
impl<T> RangeBounds<T> for Range<T>
Sourceยงimpl<T> SliceIndex<[T]> for Range<usize>
impl<T> SliceIndex<[T]> for Range<usize>
Sourceยงfn get(self, slice: &[T]) -> Option<&[T]>
fn get(self, slice: &[T]) -> Option<&[T]>
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a shared reference to the output at this location, if in
bounds.
Sourceยงfn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a mutable reference to the output at this location, if in
bounds.
Sourceยงunsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a pointer to the output at this location, without
performing any bounds checking. Read more
Sourceยงunsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a mutable pointer to the output at this location, without
performing any bounds checking. Read more
Sourceยงimpl SliceIndex<ByteStr> for Range<usize>
impl SliceIndex<ByteStr> for Range<usize>
Sourceยงfn get(
self,
slice: &ByteStr,
) -> Option<&<Range<usize> as SliceIndex<ByteStr>>::Output>
fn get( self, slice: &ByteStr, ) -> Option<&<Range<usize> as SliceIndex<ByteStr>>::Output>
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a shared reference to the output at this location, if in
bounds.
Sourceยงfn get_mut(
self,
slice: &mut ByteStr,
) -> Option<&mut <Range<usize> as SliceIndex<ByteStr>>::Output>
fn get_mut( self, slice: &mut ByteStr, ) -> Option<&mut <Range<usize> as SliceIndex<ByteStr>>::Output>
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a mutable reference to the output at this location, if in
bounds.
Sourceยงunsafe fn get_unchecked(
self,
slice: *const ByteStr,
) -> *const <Range<usize> as SliceIndex<ByteStr>>::Output
unsafe fn get_unchecked( self, slice: *const ByteStr, ) -> *const <Range<usize> as SliceIndex<ByteStr>>::Output
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a pointer to the output at this location, without
performing any bounds checking. Read more
Sourceยงunsafe fn get_unchecked_mut(
self,
slice: *mut ByteStr,
) -> *mut <Range<usize> as SliceIndex<ByteStr>>::Output
unsafe fn get_unchecked_mut( self, slice: *mut ByteStr, ) -> *mut <Range<usize> as SliceIndex<ByteStr>>::Output
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a mutable pointer to the output at this location, without
performing any bounds checking. Read more
Sourceยงimpl SliceIndex<str> for Range<usize>
impl SliceIndex<str> for Range<usize>
Sourceยงfn get(self, slice: &str) -> Option<&<Range<usize> as SliceIndex<str>>::Output>
fn get(self, slice: &str) -> Option<&<Range<usize> as SliceIndex<str>>::Output>
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a shared reference to the output at this location, if in
bounds.
Sourceยงfn get_mut(
self,
slice: &mut str,
) -> Option<&mut <Range<usize> as SliceIndex<str>>::Output>
fn get_mut( self, slice: &mut str, ) -> Option<&mut <Range<usize> as SliceIndex<str>>::Output>
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a mutable reference to the output at this location, if in
bounds.
Sourceยงunsafe fn get_unchecked(
self,
slice: *const str,
) -> *const <Range<usize> as SliceIndex<str>>::Output
unsafe fn get_unchecked( self, slice: *const str, ) -> *const <Range<usize> as SliceIndex<str>>::Output
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a pointer to the output at this location, without
performing any bounds checking. Read more
Sourceยงunsafe fn get_unchecked_mut(
self,
slice: *mut str,
) -> *mut <Range<usize> as SliceIndex<str>>::Output
unsafe fn get_unchecked_mut( self, slice: *mut str, ) -> *mut <Range<usize> as SliceIndex<str>>::Output
๐ฌThis is a nightly-only experimental API. (
slice_index_methods)Returns a mutable pointer to the output at this location, without
performing any bounds checking. Read more
impl<T> CloneFromCell for Range<T>where
T: CloneFromCell,
impl<Idx> Copy for Range<Idx>where
Idx: Copy,
impl<Idx> Eq for Range<Idx>where
Idx: Eq,
impl<Idx> StructuralPartialEq for Range<Idx>
Auto Trait Implementationsยง
impl<Idx> Freeze for Range<Idx>where
Idx: Freeze,
impl<Idx> RefUnwindSafe for Range<Idx>where
Idx: RefUnwindSafe,
impl<Idx> Send for Range<Idx>where
Idx: Send,
impl<Idx> Sync for Range<Idx>where
Idx: Sync,
impl<Idx> Unpin for Range<Idx>where
Idx: Unpin,
impl<Idx> UnwindSafe for Range<Idx>where
Idx: UnwindSafe,
Blanket Implementationsยง
Sourceยงimpl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Sourceยงimpl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Sourceยงtype Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Sourceยงtype Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Sourceยงimpl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Sourceยงtype Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Sourceยงimpl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Sourceยงtype Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Sourceยงtype Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Sourceยงimpl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Sourceยงtype Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Sourceยงimpl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Sourceยงtype Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Sourceยงtype Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Sourceยงimpl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Sourceยงimpl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Sourceยงtype Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
The
AlignTo* type which aligns Self to ALIGNMENT.Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Sourceยงimpl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงimpl<T> Pointable for T
impl<T> Pointable for T
Sourceยงimpl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
Sourceยงfn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
Converts a reference to an FFI-safe type
Sourceยงfn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
Converts an FFI-safe type to a reference
Sourceยงimpl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Sourceยงfn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
Gets a reference to a field, determined by
offset. Read moreSourceยงfn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
Gets a muatble reference to a field, determined by
offset. Read moreSourceยงfn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
Gets a const pointer to a field,
the field is determined by
offset. Read moreSourceยงfn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
Gets a mutable pointer to a field, determined by
offset. Read moreSourceยงimpl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Sourceยงfn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
Replaces a field (determined by
offset) with value,
returning the previous value of the field. Read moreSourceยงfn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Sourceยงimpl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Sourceยงfn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
Replaces a field (determined by
offset) with value,
returning the previous value of the field. Read moreSourceยงfn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Sourceยงimpl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Sourceยงfn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Emulates the pipeline operator, allowing method syntax in more places. Read more
Sourceยงfn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
The same as
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSourceยงfn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
The same as
piped, except that the function takes &mut Self.
Useful for functions that take &mut Self instead of Self.Sourceยงfn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Mutates self using a closure taking self by mutable reference,
passing it along the method chain. Read more
Sourceยงfn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Observes the value of self, passing it along unmodified.
Useful in long method chains. Read more
Sourceยงfn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
Performs a reference to reference conversion with
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read moreSourceยงimpl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Sourceยงfn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSourceยงfn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Sourceยงfn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Sourceยงfn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Sourceยงimpl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Sourceยงfn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSourceยงfn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Sourceยงunsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Sourceยงfn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Sourceยงimpl<This> TransmuteElement for Thiswhere
This: ?Sized,
impl<This> TransmuteElement for Thiswhere
This: ?Sized,
Sourceยงunsafe fn transmute_element<T>(self) -> Self::TransmutedPtrwhere
Self: CanTransmuteElement<T>,
unsafe fn transmute_element<T>(self) -> Self::TransmutedPtrwhere
Self: CanTransmuteElement<T>,
Transmutes the element type of this pointer.. Read more
Sourceยงimpl<T> TypeIdentity for Twhere
T: ?Sized,
impl<T> TypeIdentity for Twhere
T: ?Sized,
Sourceยงfn as_type_mut(&mut self) -> &mut Self::Type
fn as_type_mut(&mut self) -> &mut Self::Type
Converts a mutable reference back to the original type.
Sourceยงfn into_type_box(self: Box<Self>) -> Box<Self::Type>
fn into_type_box(self: Box<Self>) -> Box<Self::Type>
Converts a box back to the original type.
Sourceยงfn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
Converts an Arc back to the original type. Read more
Sourceยงfn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
Converts an Rc back to the original type. Read more
Sourceยงfn from_type_ref(this: &Self::Type) -> &Self
fn from_type_ref(this: &Self::Type) -> &Self
Converts a reference back to the original type.
Sourceยงfn from_type_mut(this: &mut Self::Type) -> &mut Self
fn from_type_mut(this: &mut Self::Type) -> &mut Self
Converts a mutable reference back to the original type.
Sourceยงfn from_type_box(this: Box<Self::Type>) -> Box<Self>
fn from_type_box(this: Box<Self::Type>) -> Box<Self>
Converts a box back to the original type.