Struct tagua_parser::ast::Function [] [src]

pub struct Function<'a> {
    pub name: &'a [u8],
    pub inputs: Arity<'a>,
    pub output: Ty<'a>,
    pub body: Vec<Statement<'a>>,
}

A function declaration.

Examples

use tagua_parser::Result;
use tagua_parser::ast::{
    Arity,
    Function,
    Name,
    Parameter,
    Statement,
    Ty,
    Variable
};
use tagua_parser::rules::statements::function::function;

assert_eq!(
    function(b"function f(I $x): O { return; }"),
    Result::Done(
        &b""[..],
        Statement::Function(
            Function {
                name  : &b"f"[..],
                inputs: Arity::Finite(vec![
                    Parameter {
                        ty   : Ty::Copy(Some(Name::Unqualified(&b"I"[..]))),
                        name : Variable(&b"x"[..]),
                        value: None
                    }
                ]),
                output: Ty::Copy(Some(Name::Unqualified(&b"O"[..]))),
                body  : vec![Statement::Return]
            }
        )
    )
);Run

Fields

Name of the function.

Inputs, aka parameters, of the function.

Output type of the function.

Body of the function, i.e. a set of statements.

Trait Implementations

impl<'a> Debug for Function<'a>
[src]

Formats the value using the given formatter.

impl<'a> PartialEq for Function<'a>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.