[][src]Struct rune::ast::ExprBlock

pub struct ExprBlock {
    pub async_: Option<Async>,
    pub open: OpenBrace,
    pub exprs: Vec<(Expr, Option<SemiColon>)>,
    pub trailing_expr: Option<Box<Expr>>,
    pub close: CloseBrace,
}

A block of expressions.

Fields

async_: Option<Async>

If the block is async or not.

open: OpenBrace

The close brace.

exprs: Vec<(Expr, Option<SemiColon>)>

Expressions in the block.

trailing_expr: Option<Box<Expr>>

Test if the expression is trailing.

close: CloseBrace

The close brace.

Implementations

impl ExprBlock[src]

pub fn span(&self) -> Span[src]

Get the span of the block.

pub fn produces_nothing(&self) -> bool[src]

Test if the block is empty.

pub fn is_const(&self) -> bool[src]

ExprBlock is constant if a trailing expression exists and is all literal.

Trait Implementations

impl Clone for ExprBlock[src]

impl Debug for ExprBlock[src]

impl Parse for ExprBlock[src]

Parse implementation for a block.

Examples

use rune::{parse_all, ast};

let block = parse_all::<ast::ExprBlock>("async {}")?.item;
assert_eq!(block.exprs.len(), 0);
assert!(block.trailing_expr.is_none());
assert!(block.async_.is_some());

let block = parse_all::<ast::ExprBlock>("{}")?.item;
assert_eq!(block.exprs.len(), 0);
assert!(block.trailing_expr.is_none());

let block = parse_all::<ast::ExprBlock>("{ foo }")?.item;
assert_eq!(block.exprs.len(), 0);
assert!(block.trailing_expr.is_some());

let block = parse_all::<ast::ExprBlock>("{ foo; }")?.item;
assert_eq!(block.exprs.len(), 1);
assert!(block.trailing_expr.is_none());

let block = parse_all::<ast::ExprBlock>(r#"
    {
        let foo = 42;
        let bar = "string";
        baz
    }
"#)?.item;
assert!(block.async_.is_none());
assert_eq!(block.exprs.len(), 2);
assert!(block.trailing_expr.is_some());

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,