pub struct Separated<T, P>(/* private fields */);Expand description
A punctuated sequence where trailing separator is forbidden.
Use this for function arguments or similar constructs where trailing
punctuation is invalid: f(a, b, c) not f(a, b, c,).
§Type Parameters
T: The value type (e.g., argument)P: The punctuation/separator type (e.g., comma token)
Implementations§
Source§impl<T, P> Separated<T, P>
impl<T, P> Separated<T, P>
Sourcepub const POLICY: TrailingPolicy = TrailingPolicy::Forbidden
pub const POLICY: TrailingPolicy = TrailingPolicy::Forbidden
The trailing punctuation policy for this type.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new sequence with pre-allocated capacity.
Sourcepub fn push_value(&mut self, value: T)
pub fn push_value(&mut self, value: T)
Pushes a value onto the sequence.
Sourcepub fn push_punct(&mut self, punct: P)
pub fn push_punct(&mut self, punct: P)
Attaches punctuation to the last value.
Sourcepub fn trailing_punct(&self) -> bool
pub fn trailing_punct(&self) -> bool
Returns whether the sequence has trailing punctuation.
The return value depends on the wrapper type’s policy:
Punctuated: delegates to inner storageTerminated: alwaystrueSeparated: alwaysfalse
Sourcepub fn into_inner(self) -> PunctuatedInner<T, P>
pub fn into_inner(self) -> PunctuatedInner<T, P>
Consumes the wrapper and returns the inner storage.
Methods from Deref<Target = PunctuatedInner<T, P>>§
pub fn push_value(&mut self, value: T)
pub fn push_punct(&mut self, punct: P)
pub fn trailing_punct(&self) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
pub fn reserve(&mut self, additional: usize)
pub fn shrink_to_fit(&mut self)
pub fn clear(&mut self)
pub fn iter(&self) -> impl Iterator<Item = &T>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn pairs(&self) -> impl Iterator<Item = (&T, Option<&P>)>
pub fn pairs_mut(&mut self) -> impl Iterator<Item = (&mut T, Option<&mut P>)>
pub fn first(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
Trait Implementations§
Source§impl<T, P> AsMut<PunctuatedInner<T, P>> for Separated<T, P>
impl<T, P> AsMut<PunctuatedInner<T, P>> for Separated<T, P>
Source§fn as_mut(&mut self) -> &mut PunctuatedInner<T, P>
fn as_mut(&mut self) -> &mut PunctuatedInner<T, P>
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl<T, P> AsRef<PunctuatedInner<T, P>> for Separated<T, P>
impl<T, P> AsRef<PunctuatedInner<T, P>> for Separated<T, P>
Source§fn as_ref(&self) -> &PunctuatedInner<T, P>
fn as_ref(&self) -> &PunctuatedInner<T, P>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<T, P> FromIterator<T> for Separated<T, P>
impl<T, P> FromIterator<T> for Separated<T, P>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<T, P> IntoIterator for Separated<T, P>
impl<T, P> IntoIterator for Separated<T, P>
Auto Trait Implementations§
impl<T, P> Freeze for Separated<T, P>
impl<T, P> RefUnwindSafe for Separated<T, P>where
T: RefUnwindSafe,
P: RefUnwindSafe,
impl<T, P> Send for Separated<T, P>
impl<T, P> Sync for Separated<T, P>
impl<T, P> Unpin for Separated<T, P>
impl<T, P> UnwindSafe for Separated<T, P>where
T: UnwindSafe,
P: UnwindSafe,
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
Mutably borrows from an owned value. Read more