pub struct Delimited<S, D = Delimiter> {
pub delimiter: D,
pub contents: S,
}Expand description
Syntax contained by an arbitrary or statically known delimiter family.
With its default D = Delimiter, Delimited<S> accepts any delimiter
family. Supply a crate::Delimiter! type, for example
Delimited<S, Delimiter![()]>, when the family is statically known. The
delimiter retains both boundary spans, while contents owns the syntax
between them.
use m2_syn::{Lex, Source, Span};
type ParenthesizedPlus = m2_syn::paren!(m2_syn::Token![+]);
let span = Span::unlocated(Source::synthetic(""));
let value: ParenthesizedPlus = m2_syn::paren!(
m2_syn::Token,
&span,
);
assert_eq!(value.to_m2(), "(+)");Fields§
§delimiter: DThe delimiter family and its exact opening and closing spans.
contents: SThe syntax stored between the delimiter boundaries.
Implementations§
Trait Implementations§
impl<S: Eq, D: Eq> Eq for Delimited<S, D>
Source§impl<S, D> Lex for Delimited<S, D>where
S: Lex,
D: DelimiterValue,
impl<S, D> Lex for Delimited<S, D>where
S: Lex,
D: DelimiterValue,
Source§fn to_tokens(&self, output: &mut TokenStream)
fn to_tokens(&self, output: &mut TokenStream)
Appends this value’s token trees to
output.Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Emits this value into a fresh token stream.
Source§impl<S, D> Parse for Delimited<S, D>where
S: Parse,
D: DelimiterValue,
impl<S, D> Parse for Delimited<S, D>where
S: Parse,
D: DelimiterValue,
Source§fn parse(input: &mut ParseStream) -> Result<Self, TokenParseError>
fn parse(input: &mut ParseStream) -> Result<Self, TokenParseError>
Consumes this value from
input. Read moreSource§impl<S, D> PrettyTree for Delimited<S, D>
Available on crate feature pretty only.
impl<S, D> PrettyTree for Delimited<S, D>
Available on crate feature
pretty only.Source§fn pretty_tree(&self) -> PrettyNode
fn pretty_tree(&self) -> PrettyNode
Builds the presentation node for this syntax value.
Source§impl<S, D> Spanned for Delimited<S, D>
impl<S, D> Spanned for Delimited<S, D>
impl<S: PartialEq, D: PartialEq> StructuralPartialEq for Delimited<S, D>
Auto Trait Implementations§
impl<S, D> Freeze for Delimited<S, D>
impl<S, D> RefUnwindSafe for Delimited<S, D>where
D: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, D> Send for Delimited<S, D>
impl<S, D> Sync for Delimited<S, D>
impl<S, D> Unpin for Delimited<S, D>
impl<S, D> UnsafeUnpin for Delimited<S, D>where
D: UnsafeUnpin,
S: UnsafeUnpin,
impl<S, D> UnwindSafe for Delimited<S, D>where
D: UnwindSafe,
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