pub struct Unary {
pub operand: Box<Expr>,
pub op: UnaryOp,
pub span: Range<usize>,
}Expand description
A unary expression, such as 2!. Unary expressions can include nested expressions.
Fields§
§operand: Box<Expr>The operand of the unary expression (left or right, depending on the associativity).
op: UnaryOpThe operator of the unary expression.
span: Range<usize>The region of the source code that this unary expression was parsed from.
Implementations§
Source§impl Unary
impl Unary
Sourcepub fn parse_right(
input: &mut Parser<'_>,
recoverable_errors: &mut Vec<Error>,
) -> Result<Self, Vec<Error>>
pub fn parse_right( input: &mut Parser<'_>, recoverable_errors: &mut Vec<Error>, ) -> Result<Self, Vec<Error>>
Parse a unary expression with right-associativity.
Sourcepub fn parse_left_or_operand(
input: &mut Parser<'_>,
recoverable_errors: &mut Vec<Error>,
) -> Result<Expr, Vec<Error>>
pub fn parse_left_or_operand( input: &mut Parser<'_>, recoverable_errors: &mut Vec<Error>, ) -> Result<Expr, Vec<Error>>
Parse a unary expression with left-associativity.
By the nature of left-associative operators, we must parse the operand first. This can
result in enormous backtracking if the operator is not present. To avoid this, this
function returns the parsed operand as an Primary if it does determine that there
is no operator present.
Trait Implementations§
Source§impl Latex for Unary
impl Latex for Unary
Source§fn as_display(&self) -> LatexFormatter<'_, Self>
fn as_display(&self) -> LatexFormatter<'_, Self>
Wraps the value in a
LatexFormatter, which implements Display.Source§impl<'source> Parse<'source> for Unary
impl<'source> Parse<'source> for Unary
impl Eq for Unary
impl StructuralPartialEq for Unary
Auto Trait Implementations§
impl Freeze for Unary
impl RefUnwindSafe for Unary
impl Send for Unary
impl Sync for Unary
impl Unpin for Unary
impl UnwindSafe for Unary
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