pub struct PostfixExpr<Operand, Operator, const MAX: usize = unsynn::::expressions::PostfixExpr::{constant#0}> {
pub operand: Operand,
pub operators: DelimitedVec<Operator, Nothing, Mandatory, 0, MAX>,
}Expand description
Postfix unary operator expression.
Parses: Operand Op* (operand, then 0 to MAX operators)
Allows zero or more postfix operators after an operand. Multiple postfix operators
are applied left-to-right (leftmost first). For example, x?? is parsed as
(x?)? (try operators chain left-to-right).
§Type Parameters
Operand: The type of expression that the operators apply toOperator: The postfix operator type (typically an enum of different postfix operations)MAX: Maximum number of postfix operators (defaults tousize::MAXfor unlimited)
§Examples
unsynn! {
type Number = LiteralInteger;
}
// Parse "5 ! !"
let mut tokens = "5 ! !".to_token_iter();
let expr: PostfixExpr<Number, Bang> = tokens.parse().unwrap();
assert_eq!(expr.operators.len(), 2); // 2 Bang operators
// Limit postfix depth
type LimitedPostfix = PostfixExpr<Number, Bang, 3>; // Max 3 postfix operatorsFields§
§operand: OperandThe operand that the operators apply to
operators: DelimitedVec<Operator, Nothing, Mandatory, 0, MAX>The postfix operators (0 to MAX, applied left-to-right)
Implementations§
Source§impl<Operand, Operator, const MAX: usize> PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> PostfixExpr<Operand, Operator, MAX>
Sourcepub const fn new(
operand: Operand,
operators: DelimitedVec<Operator, Nothing, Mandatory, 0, MAX>,
) -> PostfixExpr<Operand, Operator, MAX>
pub const fn new( operand: Operand, operators: DelimitedVec<Operator, Nothing, Mandatory, 0, MAX>, ) -> PostfixExpr<Operand, Operator, MAX>
Create a new PostfixExpr with the given operand and operators.
Trait Implementations§
Source§impl<Operand, Operator, const MAX: usize> Clone for PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> Clone for PostfixExpr<Operand, Operator, MAX>
Source§fn clone(&self) -> PostfixExpr<Operand, Operator, MAX>
fn clone(&self) -> PostfixExpr<Operand, Operator, MAX>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Operand, Operator, const MAX: usize> Debug for PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> Debug for PostfixExpr<Operand, Operator, MAX>
Source§impl<Operand, Operator, const MAX: usize> Parser for PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> Parser for PostfixExpr<Operand, Operator, MAX>
Source§fn parser(
tokens: &mut TokenIter,
) -> Result<PostfixExpr<Operand, Operator, MAX>, Error>
fn parser( tokens: &mut TokenIter, ) -> Result<PostfixExpr<Operand, Operator, MAX>, Error>
The actual parsing function that must be implemented. This mutates the
tokens
iterator directly. It should not be called from user code except for implementing
parsers itself and then only when the rules below are followed. Read moreSource§impl<Operand, Operator, const MAX: usize> ToTokens for PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> ToTokens for PostfixExpr<Operand, Operator, MAX>
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn into_token_iter(self) -> TokenIter ⓘwhere
Self: Sized,
fn into_token_iter(self) -> TokenIter ⓘwhere
Self: Sized,
Convert
self into a TokenIter object.Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Convert
&self into a TokenStream object.Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Convert
self into a TokenStream object.Auto Trait Implementations§
impl<Operand, Operator, const MAX: usize> Freeze for PostfixExpr<Operand, Operator, MAX>where
Operand: Freeze,
impl<Operand, Operator, const MAX: usize> RefUnwindSafe for PostfixExpr<Operand, Operator, MAX>where
Operand: RefUnwindSafe,
Operator: RefUnwindSafe,
impl<Operand, Operator, const MAX: usize> Send for PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> Sync for PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> Unpin for PostfixExpr<Operand, Operator, MAX>
impl<Operand, Operator, const MAX: usize> UnwindSafe for PostfixExpr<Operand, Operator, MAX>where
Operand: UnwindSafe,
Operator: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynamicTokens for T
impl<T> DynamicTokens for T
Source§impl<T> Parse for Twhere
T: Parser,
impl<T> Parse for Twhere
T: Parser,
Source§fn parse(tokens: &mut TokenIter) -> Result<Self, Error>
fn parse(tokens: &mut TokenIter) -> Result<Self, Error>
This is the user facing API to parse grammatical entities. Calls a
parser() within a
transaction. Commits changes on success and returns the parsed value. Read more