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§
Source§impl Arbitrary for RangeFull
impl Arbitrary for RangeFull
Source§type Parameters = ()
type Parameters = ()
arbitrary_with
accepts for configuration
of the generated Strategy
. Parameters must implement Default
.Source§fn arbitrary_with(
_args: <RangeFull as Arbitrary>::Parameters,
) -> <RangeFull as Arbitrary>::Strategy
fn arbitrary_with( _args: <RangeFull as Arbitrary>::Parameters, ) -> <RangeFull as Arbitrary>::Strategy
Source§impl<C1> ContainsToken<C1> for RangeFullwhere
C1: AsChar,
impl<C1> ContainsToken<C1> for RangeFullwhere
C1: AsChar,
Source§fn contains_token(&self, _token: C1) -> bool
fn contains_token(&self, _token: C1) -> bool
Source§impl From<RangeFull> for ValueParser
impl From<RangeFull> for ValueParser
Create an i64
ValueParser
from a ..
range
See RangedI64ValueParser
for more control over the output type.
See also RangedU64ValueParser
§Examples
let mut cmd = clap::Command::new("raw")
.arg(
clap::Arg::new("port")
.long("port")
.value_parser(..)
.action(clap::ArgAction::Set)
.required(true)
);
let m = cmd.try_get_matches_from_mut(["cmd", "--port", "3001"]).unwrap();
let port: i64 = *m.get_one("port")
.expect("required");
assert_eq!(port, 3001);
Source§fn from(value: RangeFull) -> ValueParser
fn from(value: RangeFull) -> ValueParser
Source§impl From<RangeFull> for ValueRange
impl From<RangeFull> for ValueRange
Source§fn from(_: RangeFull) -> ValueRange
fn from(_: RangeFull) -> ValueRange
Source§impl Index<RangeFull> for UninitSlice
impl Index<RangeFull> for UninitSlice
Source§type Output = UninitSlice
type Output = UninitSlice
Source§impl IndexMut<RangeFull> for UninitSlice
impl IndexMut<RangeFull> for UninitSlice
Source§impl<I> IteratorIndex<I> for RangeFullwhere
I: Iterator,
impl<I> IteratorIndex<I> for RangeFullwhere
I: Iterator,
Source§impl<I> IteratorIndex<I> for RangeFullwhere
I: Iterator,
impl<I> IteratorIndex<I> for RangeFullwhere
I: Iterator,
Source§impl NomRange<usize> for RangeFull
impl NomRange<usize> for RangeFull
Source§type Saturating = SaturatingIterator
type Saturating = SaturatingIterator
Source§fn is_inverted(&self) -> bool
fn is_inverted(&self) -> bool
true
if the range is inverted.Source§fn saturating_iter(&self) -> <RangeFull as NomRange<usize>>::Saturating
fn saturating_iter(&self) -> <RangeFull as NomRange<usize>>::Saturating
Source§fn bounded_iter(&self) -> <RangeFull as NomRange<usize>>::Bounded
fn bounded_iter(&self) -> <RangeFull as NomRange<usize>>::Bounded
None
for all further elements.1.28.0 · Source§impl<T> RangeBounds<T> for RangeFullwhere
T: ?Sized,
impl<T> RangeBounds<T> for RangeFullwhere
T: ?Sized,
1.15.0 · Source§impl<T> SliceIndex<[T]> for RangeFull
impl<T> SliceIndex<[T]> for RangeFull
Source§fn get(self, slice: &[T]) -> Option<&[T]>
fn get(self, slice: &[T]) -> Option<&[T]>
slice_index_methods
)Source§fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]>
slice_index_methods
)Source§unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T]
slice_index_methods
)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
)1.20.0 · 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]
.
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
)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
)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
)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
)Source§impl<'data> TryFrom<&RangeFull> for CodePointInversionList<'data>
impl<'data> TryFrom<&RangeFull> for CodePointInversionList<'data>
Source§type Error = CodePointInversionListError
type Error = CodePointInversionListError
Source§fn try_from(
_: &RangeFull,
) -> Result<CodePointInversionList<'data>, <CodePointInversionList<'data> as TryFrom<&RangeFull>>::Error>
fn try_from( _: &RangeFull, ) -> Result<CodePointInversionList<'data>, <CodePointInversionList<'data> as TryFrom<&RangeFull>>::Error>
impl Copy for RangeFull
impl Eq for RangeFull
impl StructuralPartialEq for RangeFull
Auto Trait Implementations§
impl Freeze for RangeFull
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 more