[][src]Struct rune::ast::DeclFn

pub struct DeclFn {
    pub async_: Option<Async>,
    pub fn_: Fn,
    pub name: Ident,
    pub args: Parenthesized<FnArg, Comma>,
    pub body: ExprBlock,
}

A function.

Fields

async_: Option<Async>

The optional async keyword.

fn_: Fn

The fn token.

name: Ident

The name of the function.

args: Parenthesized<FnArg, Comma>

The arguments of the function.

body: ExprBlock

The body of the function.

Implementations

impl DeclFn[src]

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

Get the identifying span for this function.

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

Access the span for the function declaration.

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

Test if function is an instance fn.

Trait Implementations

impl Clone for DeclFn[src]

impl Debug for DeclFn[src]

impl Parse for DeclFn[src]

Parse implementation for a function.

Examples

use rune::{ParseAll, parse_all, ast, Resolve as _};

parse_all::<ast::DeclFn>("async fn hello() {}").unwrap();
assert!(parse_all::<ast::DeclFn>("fn async hello() {}").is_err());

let ParseAll { item, .. } = parse_all::<ast::DeclFn>("fn hello() {}").unwrap();
assert_eq!(item.args.items.len(), 0);

let ParseAll  { source, item } = parse_all::<ast::DeclFn>("fn hello(foo, bar) {}").unwrap();
assert_eq!(item.args.items.len(), 2);
assert_eq!(item.name.resolve(source).unwrap(), "hello");

Auto Trait Implementations

impl RefUnwindSafe for DeclFn

impl Send for DeclFn

impl Sync for DeclFn

impl Unpin for DeclFn

impl UnwindSafe for DeclFn

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>,