pub struct RangeFull;
Expand description
An unbounded range (..
).
RangeFull
is primarily used as a slicing index, its shorthand is ..
.
It cannot serve as an Iterator
because it doesn’t have a starting point.
Examples
The ..
syntax is a RangeFull
:
assert_eq!(.., std::ops::RangeFull);
It does not have an IntoIterator
implementation, so you can’t use it in
a for
loop directly. This won’t compile:
for i in .. {
// ...
}
Used as a slicing index, RangeFull
produces the full array as a slice.
let arr = [0, 1, 2, 3, 4];
assert_eq!(arr[ .. ], [0, 1, 2, 3, 4]); // This is the `RangeFull`
assert_eq!(arr[ .. 3], [0, 1, 2 ]);
assert_eq!(arr[ ..=3], [0, 1, 2, 3 ]);
assert_eq!(arr[1.. ], [ 1, 2, 3, 4]);
assert_eq!(arr[1.. 3], [ 1, 2 ]);
assert_eq!(arr[1..=3], [ 1, 2, 3 ]);
Trait Implementations§
1.28.0 · source§impl<T> RangeBounds<T> for RangeFullwhere
T: ?Sized,
impl<T> RangeBounds<T> for RangeFullwhere
T: ?Sized,
1.15.0 (const: unstable) · source§impl<T> SliceIndex<[T]> for RangeFull
impl<T> SliceIndex<[T]> for RangeFull
const: unstable · source§fn get(self, slice: &[T]) -> Option<&[T]>
fn get(self, slice: &[T]) -> Option<&[T]>
slice_index_methods
)const: unstable · source§fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
slice_index_methods
)const: unstable · source§unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
slice_index_methods
)slice
pointer
is undefined behavior even if the resulting reference is not used.const: unstable · source§unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
slice_index_methods
)slice
pointer
is undefined behavior even if the resulting reference is not used.1.20.0 (const: unstable) · source§impl SliceIndex<str> for RangeFull
impl SliceIndex<str> for RangeFull
Implements substring slicing with syntax &self[..]
or &mut self[..]
.
Returns a slice of the whole string, i.e., returns &self
or &mut self
. Equivalent to &self[0 .. len]
or &mut self[0 .. len]
. Unlike
other indexing operations, this can never panic.
This operation is O(1).
Prior to 1.20.0, these indexing operations were still supported by
direct implementation of Index
and IndexMut
.
Equivalent to &self[0 .. len]
or &mut self[0 .. len]
.
const: unstable · source§fn get(self, slice: &str) -> Option<&<RangeFull as SliceIndex<str>>::Output>
fn get(self, slice: &str) -> Option<&<RangeFull as SliceIndex<str>>::Output>
slice_index_methods
)const: unstable · source§fn get_mut(
self,
slice: &mut str
) -> Option<&mut <RangeFull as SliceIndex<str>>::Output>
fn get_mut( self, slice: &mut str ) -> Option<&mut <RangeFull as SliceIndex<str>>::Output>
slice_index_methods
)const: unstable · source§unsafe fn get_unchecked(
self,
slice: *const str
) -> *const <RangeFull as SliceIndex<str>>::Output
unsafe fn get_unchecked( self, slice: *const str ) -> *const <RangeFull as SliceIndex<str>>::Output
slice_index_methods
)slice
pointer
is undefined behavior even if the resulting reference is not used.const: unstable · source§unsafe fn get_unchecked_mut(
self,
slice: *mut str
) -> *mut <RangeFull as SliceIndex<str>>::Output
unsafe fn get_unchecked_mut( self, slice: *mut str ) -> *mut <RangeFull as SliceIndex<str>>::Output
slice_index_methods
)slice
pointer
is undefined behavior even if the resulting reference is not used.impl Copy for RangeFull
impl Eq for RangeFull
impl StructuralEq for RangeFull
impl StructuralPartialEq for RangeFull
Auto Trait Implementations§
impl RefUnwindSafe for RangeFull
impl Send for RangeFull
impl Sync for RangeFull
impl Unpin for RangeFull
impl UnwindSafe for RangeFull
Blanket Implementations§
source§impl<T> Also for T
impl<T> Also for T
source§impl<T> AnyExt for Twhere
T: Any,
impl<T> AnyExt for Twhere
T: Any,
source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
any
only.self
. Read moresource§fn as_any_ref(&self) -> &dyn Anywhere
Self: Sized,
fn as_any_ref(&self) -> &dyn Anywhere
Self: Sized,
any
only.source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
any
only.source§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
source§fn apply<F: FnOnce(Self) -> Res>(self, f: F) -> Reswhere
Self: Sized,
fn apply<F: FnOnce(Self) -> Res>(self, f: F) -> Reswhere
Self: Sized,
result
only.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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
source§impl<T> Mem for Twhere
T: ?Sized,
impl<T> Mem for Twhere
T: ?Sized,
source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
mem
only.source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
mem
only.true
if dropping values of this type matters.source§fn mem_drop(self)where
Self: Sized,
fn mem_drop(self)where
Self: Sized,
mem
only.self
by running its destructor.source§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
mem
only.self
without running its destructor.source§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
mem
only.self
with other, returning the previous value of self
.source§fn mem_take(&mut self) -> Selfwhere
Self: Default,
fn mem_take(&mut self) -> Selfwhere
Self: Default,
mem
only.self
with its default value, returning the previous value of self
.source§fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
mem
only.self
and other
without deinitializing either one.source§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
mem
and unsafe_mem
only.source§impl<T> Size for T
impl<T> Size for T
source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
mem
only.source§const BYTE_SIZE: usize = _
const BYTE_SIZE: usize = _
mem
only.source§const PTR_SIZE: usize = 8usize
const PTR_SIZE: usize = 8usize
mem
only.source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
mem
only.