Struct rune::ast::ExprClosure[][src]

pub struct ExprClosure {
    pub id: Option<Id>,
    pub attributes: Vec<Attribute>,
    pub async_token: Option<Async>,
    pub move_token: Option<Move>,
    pub args: ExprClosureArgs,
    pub body: Expr,
}

A closure expression.

Examples

use rune::{testing, ast};

testing::roundtrip::<ast::ExprClosure>("async || 42");
testing::roundtrip::<ast::ExprClosure>("|| 42");
testing::roundtrip::<ast::ExprClosure>("|| { 42 }");
testing::roundtrip::<ast::ExprClosure>("move || { 42 }");
testing::roundtrip::<ast::ExprClosure>("async move || { 42 }");

let expr = testing::roundtrip::<ast::ExprClosure>("#[retry(n=3)]  || 43");
assert_eq!(expr.attributes.len(), 1);

let expr = testing::roundtrip::<ast::ExprClosure>("#[retry(n=3)] async || 43");
assert_eq!(expr.attributes.len(), 1);

Fields

id: Option<Id>

Opaque identifier for the closure.

attributes: Vec<Attribute>

The attributes for the async closure

async_token: Option<Async>

If the closure is async or not.

move_token: Option<Move>

If the closure moves data into it.

args: ExprClosureArgs

Arguments to the closure.

body: Expr

The body of the closure.

Implementations

impl ExprClosure[src]

pub fn parse_with_meta(
    parser: &mut Parser<'_>,
    attributes: Vec<Attribute>,
    async_token: Option<Async>,
    move_token: Option<Move>
) -> Result<Self, ParseError>
[src]

Parse #ident and attach the given meta

impl ExprClosure[src]

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

Get the identifying span for this closure.

Trait Implementations

impl Clone for ExprClosure[src]

impl Debug for ExprClosure[src]

impl Eq for ExprClosure[src]

impl Parse for ExprClosure[src]

impl PartialEq<ExprClosure> for ExprClosure[src]

impl Spanned for ExprClosure[src]

impl StructuralEq for ExprClosure[src]

impl StructuralPartialEq for ExprClosure[src]

impl ToTokens for ExprClosure[src]

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.