Enum rune::ast::Expr [−][src]
A rune expression.
Variants
An path expression.
A declaration.
Assign(Box<ExprAssign>)
An assign expression.
A while loop.
An unconditional loop.
An for loop.
A let expression.
An if expression.
An match expression.
A function call,
FieldAccess(Box<ExprFieldAccess>)
A field access on an expression.
A grouped expression.
Binary(Box<ExprBinary>)
A binary expression.
A unary expression.
An index set operation.
A break expression.
Continue(Box<ExprContinue>)
A continue expression.
A yield expression.
A block as an expression.
Return(Box<ExprReturn>)
A return statement.
An await expression.
Try expression.
Select(Box<ExprSelect>)
A select expression.
Closure(Box<ExprClosure>)
A closure expression.
A literal expression.
Force a specific semi-colon policy.
A macro call,
Object(Box<ExprObject>)
An object literal
A tuple literal
A vec literal
A range expression.
Implementations
impl Expr
[src]
pub fn needs_semi(&self) -> bool
[src]
Indicates if an expression needs a semicolon or must be last in a block.
pub fn is_callable(&self, callable: bool) -> bool
[src]
Indicates if an expression is callable unless it’s permitted by an override.
pub fn take_attributes(&mut self) -> Vec<Attribute>
[src]
Take the attributes from the expression.
pub fn attributes(&self) -> &[Attribute]
[src]
Access the attributes of the expression.
pub fn is_lit(&self) -> bool
[src]
Check if this expression is a literal expression.
There are exactly two kinds of literal expressions:
- Ones that are ExprLit
- Unary expressions which are the negate operation.
pub fn parse_open_paren(
p: &mut Parser<'_>,
attributes: Vec<Attribute>
) -> Result<Self, ParseError>
[src]
p: &mut Parser<'_>,
attributes: Vec<Attribute>
) -> Result<Self, ParseError>
Parsing something that opens with a parenthesis.
Trait Implementations
impl Clone for Expr
[src]
impl Debug for Expr
[src]
impl Eq for Expr
[src]
impl Parse for Expr
[src]
Parsing a block expression.
Examples
use rune::{testing, ast}; testing::roundtrip::<ast::Expr>("()"); testing::roundtrip::<ast::Expr>("foo[\"foo\"]"); testing::roundtrip::<ast::Expr>("foo.bar()"); testing::roundtrip::<ast::Expr>("var()"); testing::roundtrip::<ast::Expr>("var"); testing::roundtrip::<ast::Expr>("42"); testing::roundtrip::<ast::Expr>("1 + 2 / 3 - 4 * 1"); testing::roundtrip::<ast::Expr>("foo[\"bar\"]"); testing::roundtrip::<ast::Expr>("let var = 42"); testing::roundtrip::<ast::Expr>("let var = \"foo bar\""); testing::roundtrip::<ast::Expr>("var[\"foo\"] = \"bar\""); testing::roundtrip::<ast::Expr>("let var = objects[\"foo\"] + 1"); testing::roundtrip::<ast::Expr>("var = 42"); let expr = testing::roundtrip::<ast::Expr>(r#" if 1 { } else { if 2 { } else { } } "#); assert!(matches!(expr, ast::Expr::If(..))); // Chained function calls. testing::roundtrip::<ast::Expr>("foo.bar.baz()"); testing::roundtrip::<ast::Expr>("foo[0][1][2]"); testing::roundtrip::<ast::Expr>("foo.bar()[0].baz()[1]"); testing::roundtrip::<ast::Expr>("42 is int::int"); testing::roundtrip::<ast::Expr>("{ let x = 1; x }"); let expr = testing::roundtrip::<ast::Expr>("#[cfg(debug_assertions)] { assert_eq(x, 32); }"); assert!(matches!(expr, ast::Expr::Block(b) if b.attributes.len() == 1 && b.block.statements.len() == 1)); testing::roundtrip::<ast::Expr>("#{\"foo\": b\"bar\"}"); testing::roundtrip::<ast::Expr>("Disco {\"never_died\": true }"); testing::roundtrip::<ast::Expr>("(false, 1, 'n')"); testing::roundtrip::<ast::Expr>("[false, 1, 'b']");
fn parse(p: &mut Parser<'_>) -> Result<Self, ParseError>
[src]
impl PartialEq<Expr> for Expr
[src]
impl Peek for Expr
[src]
impl Spanned for Expr
[src]
impl StructuralEq for Expr
[src]
impl StructuralPartialEq for Expr
[src]
impl ToTokens for Expr
[src]
fn to_tokens(&self, context: &MacroContext, stream: &mut TokenStream)
[src]
Auto Trait Implementations
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnwindSafe for Expr
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,