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);RunIt does not have an IntoIterator implementation, so you can’t use it in
a for loop directly. This won’t compile:
for i in .. {
// ...
}RunUsed 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 ]);RunTrait Implementations
impl<T> RangeBounds<T> for RangeFull where
T: ?Sized,
1.28.0 · source
impl<T> RangeBounds<T> for RangeFull where
T: ?Sized,
1.28.0 · sourceimpl<T> SliceIndex<[T]> for RangeFull
1.15.0 (const: unstable) · source
impl<T> SliceIndex<[T]> for RangeFull
1.15.0 (const: unstable) · sourcefn get(self, slice: &[T]) -> Option<&[T]>
const: unstable · source
fn get(self, slice: &[T]) -> Option<&[T]>
const: unstable · sourceslice_index_methods)Returns a shared reference to the output at this location, if in bounds. Read more
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
const: unstable · source
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
const: unstable · sourceslice_index_methods)Returns a mutable reference to the output at this location, if in bounds. Read more
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
const: unstable · source
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
const: unstable · sourceslice_index_methods)Returns a shared reference to the output at this location, without
performing any bounds checking.
Calling this method with an out-of-bounds index or a dangling slice pointer
is undefined behavior even if the resulting reference is not used. Read more
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
const: unstable · source
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T]
const: unstable · sourceslice_index_methods)Returns a mutable reference to the output at this location, without
performing any bounds checking.
Calling this method with an out-of-bounds index or a dangling slice pointer
is undefined behavior even if the resulting reference is not used. Read more
fn index(self, slice: &[T]) -> &[T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
const: unstable · source
fn index(self, slice: &[T]) -> &[T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
const: unstable · sourceslice_index_methods)Returns a shared reference to the output at this location, panicking if out of bounds. Read more
fn index_mut(self, slice: &mut [T]) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
const: unstable · source
fn index_mut(self, slice: &mut [T]) -> &mut [T]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
const: unstable · sourceslice_index_methods)Returns a mutable reference to the output at this location, panicking if out of bounds. Read more
impl SliceIndex<str> for RangeFull
1.20.0 (const: unstable) · source
impl SliceIndex<str> for RangeFull
1.20.0 (const: unstable) · sourceImplements 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].
fn get(self, slice: &str) -> Option<&<RangeFull as SliceIndex<str>>::Output>
const: unstable · source
fn get(self, slice: &str) -> Option<&<RangeFull as SliceIndex<str>>::Output>
const: unstable · sourceslice_index_methods)Returns a shared reference to the output at this location, if in bounds. Read more
fn get_mut(
self,
slice: &mut str
) -> Option<&mut <RangeFull as SliceIndex<str>>::Output>
const: unstable · source
fn get_mut(
self,
slice: &mut str
) -> Option<&mut <RangeFull as SliceIndex<str>>::Output>
const: unstable · sourceslice_index_methods)Returns a mutable reference to the output at this location, if in bounds. Read more
unsafe fn get_unchecked(
self,
slice: *const str
) -> *const <RangeFull as SliceIndex<str>>::Output
const: unstable · source
unsafe fn get_unchecked(
self,
slice: *const str
) -> *const <RangeFull as SliceIndex<str>>::Output
const: unstable · sourceslice_index_methods)Returns a shared reference to the output at this location, without
performing any bounds checking.
Calling this method with an out-of-bounds index or a dangling slice pointer
is undefined behavior even if the resulting reference is not used. Read more
unsafe fn get_unchecked_mut(
self,
slice: *mut str
) -> *mut <RangeFull as SliceIndex<str>>::Output
const: unstable · source
unsafe fn get_unchecked_mut(
self,
slice: *mut str
) -> *mut <RangeFull as SliceIndex<str>>::Output
const: unstable · sourceslice_index_methods)Returns a mutable reference to the output at this location, without
performing any bounds checking.
Calling this method with an out-of-bounds index or a dangling slice pointer
is undefined behavior even if the resulting reference is not used. Read more
impl Copy for RangeFull
sourceimpl Eq for RangeFull
sourceimpl StructuralEq for RangeFull
sourceimpl StructuralPartialEq for RangeFull
sourceAuto Trait Implementations
impl RefUnwindSafe for RangeFull
impl Send for RangeFull
impl Sync for RangeFull
impl Unpin for RangeFull
impl UnwindSafe for RangeFull
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
source
impl<T> BorrowMut<T> for T where
T: ?Sized,
sourcefn borrow_mut(&mut self) -> &mut T
const: unstable · source
fn borrow_mut(&mut self) -> &mut T
const: unstable · sourceMutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
source
impl<T> ToOwned for T where
T: Clone,
sourcetype Owned = T
type Owned = T
The resulting type after obtaining ownership.
fn clone_into(&self, target: &mut T)
source
fn clone_into(&self, target: &mut T)
sourceUses borrowed data to replace owned data, usually by cloning. Read more