Struct tagua_parser::ast::Parameter
[−]
[src]
pub struct Parameter<'a> { pub ty: Ty<'a>, pub name: Variable<'a>, pub value: Option<Expression<'a>>, }
A parameter, aka input, of a function.
A parameter can:
- be typed or not,
- be passed by copy, or by reference,
- have a default constant value.
Examples
use tagua_parser::Result; use tagua_parser::ast::{ Arity, Expression, Literal, Name, Parameter, Ty, Variable }; use tagua_parser::rules::statements::function::parameters; assert_eq!( parameters(b"($x = 42, I &$y)"), Result::Done( &b""[..], Arity::Finite(vec![ Parameter { ty : Ty::Copy(None), name : Variable(&b"x"[..]), value: Some(Expression::Literal(Literal::Integer(42i64))) }, Parameter { ty : Ty::Reference(Some(Name::Unqualified(&b"I"[..]))), name : Variable(&b"y"[..]), value: None } ]) ) );Run
Fields
ty: Ty<'a>
Type of the parameter.
name: Variable<'a>
Name of the parameter.
value: Option<Expression<'a>>
Default value of the parameter.