pub struct DeclareVarStmt<Type, Expr>(pub Type, pub Expr);Expand description
Declares a new variable. Renders as Type Expr; with a new line at the end
The expression can be either the variable name or an AssignExpr.
let declare_var = DeclareVarStmt(Str("String"), Str("varname"));
let string = InMemoryOutput::print_output(EmptyContext, &declare_var);
assert_eq!("String varname;\n", string);
let init_var = DeclareVarStmt(Str("String"), AssignExpr(Str("varname"), Str("\"hello world\"")));
let string = InMemoryOutput::print_output(EmptyContext, &init_var);
assert_eq!("String varname = \"hello world\";\n", string);Tuple Fields§
§0: Type§1: ExprTrait Implementations§
Auto Trait Implementations§
impl<Type, Expr> Freeze for DeclareVarStmt<Type, Expr>
impl<Type, Expr> RefUnwindSafe for DeclareVarStmt<Type, Expr>where
Type: RefUnwindSafe,
Expr: RefUnwindSafe,
impl<Type, Expr> Send for DeclareVarStmt<Type, Expr>
impl<Type, Expr> Sync for DeclareVarStmt<Type, Expr>
impl<Type, Expr> Unpin for DeclareVarStmt<Type, Expr>
impl<Type, Expr> UnwindSafe for DeclareVarStmt<Type, Expr>where
Type: UnwindSafe,
Expr: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more