pub struct Punctuated<S> { /* private fields */ }Expand description
A sequence of syntax values separated by typed comma tokens.
Ordinary iteration exposes only values. Use Punctuated::pairs or
Punctuated::into_pairs when punctuation and its spans are significant.
use m2_syn::{Span, ToTokens};
type Pluses = m2_syn::punct!(m2_syn::Token![+]);
let comma = m2_syn::Token);
let values: Pluses = m2_syn::punct!(
pairs m2_syn::Token);
comma => m2_syn::Token),
);
assert_eq!(values.to_m2(), "+,+");Implementations§
Source§impl<S> Punctuated<S>
impl<S> Punctuated<S>
Sourcepub fn from_value(value: S) -> Self
pub fn from_value(value: S) -> Self
Creates a sequence containing one value.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, S> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, S> ⓘ
Mutably borrows the values without exposing punctuation.
Sourcepub fn pairs(&self) -> Pairs<'_, S> ⓘ
pub fn pairs(&self) -> Pairs<'_, S> ⓘ
Borrows values together with their optional following commas.
Sourcepub fn pairs_mut(&mut self) -> PairsMut<'_, S> ⓘ
pub fn pairs_mut(&mut self) -> PairsMut<'_, S> ⓘ
Mutably borrows values together with their optional following commas.
Sourcepub fn into_pairs(self) -> IntoPairs<S> ⓘ
pub fn into_pairs(self) -> IntoPairs<S> ⓘ
Consumes the sequence while preserving commas in the yielded pairs.
Sourcepub fn push(&mut self, punctuation: _Cma, next: S)
pub fn push(&mut self, punctuation: _Cma, next: S)
Adds a comma and the component on its right.
Panics if the sequence is empty. Empty components must be represented
explicitly by converting Empty into S before calling this method.
Sourcepub fn map<T>(self, map: impl FnMut(S) -> T) -> Punctuated<T>
pub fn map<T>(self, map: impl FnMut(S) -> T) -> Punctuated<T>
Transforms the values while retaining every comma token and its span.
Trait Implementations§
Source§impl<S: Clone> Clone for Punctuated<S>
impl<S: Clone> Clone for Punctuated<S>
Source§fn clone(&self) -> Punctuated<S>
fn clone(&self) -> Punctuated<S>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<S: Debug> Debug for Punctuated<S>
impl<S: Debug> Debug for Punctuated<S>
Source§impl<S> Default for Punctuated<S>
impl<S> Default for Punctuated<S>
impl<S: Eq> Eq for Punctuated<S>
Source§impl<S> FromIterator<S> for Punctuated<S>
impl<S> FromIterator<S> for Punctuated<S>
Source§fn from_iter<T: IntoIterator<Item = S>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = S>>(iter: T) -> Self
Creates a value from an iterator. Read more
Source§impl<S> IntoIterator for Punctuated<S>
impl<S> IntoIterator for Punctuated<S>
Source§impl<'a, S> IntoIterator for &'a Punctuated<S>
impl<'a, S> IntoIterator for &'a Punctuated<S>
Source§impl<'a, S> IntoIterator for &'a mut Punctuated<S>
impl<'a, S> IntoIterator for &'a mut Punctuated<S>
Source§impl<S> Parse for Punctuated<S>
impl<S> Parse for Punctuated<S>
fn parse(input: &mut ParseStream) -> Result<Self, TokenParseError>
Source§impl<S: PartialEq> PartialEq for Punctuated<S>
impl<S: PartialEq> PartialEq for Punctuated<S>
Source§impl<T: PrettyTree + Spanned> PrettyTree for Punctuated<T>
impl<T: PrettyTree + Spanned> PrettyTree for Punctuated<T>
Source§fn pretty_tree(&self) -> PrettyNode
fn pretty_tree(&self) -> PrettyNode
Builds the presentation node for this syntax value.
Source§impl<S> Spanned for Punctuated<S>
impl<S> Spanned for Punctuated<S>
impl<S: PartialEq> StructuralPartialEq for Punctuated<S>
Auto Trait Implementations§
impl<S> Freeze for Punctuated<S>
impl<S> RefUnwindSafe for Punctuated<S>where
S: RefUnwindSafe,
impl<S> Send for Punctuated<S>where
S: Send,
impl<S> Sync for Punctuated<S>where
S: Sync,
impl<S> Unpin for Punctuated<S>where
S: Unpin,
impl<S> UnsafeUnpin for Punctuated<S>
impl<S> UnwindSafe for Punctuated<S>where
S: 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