DeclareVarStmt

Struct DeclareVarStmt 

Source
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: Expr

Trait Implementations§

Source§

impl<O, Type, Expr> Writable<O> for DeclareVarStmt<Type, Expr>
where O: Output, Type: Writable<O>, Expr: Writable<O>,

Source§

async fn write_to(&self, output: &mut O) -> Result<(), O::Error>

Writes to the output. Returns the output’s error upon failure. Read more

Auto Trait Implementations§

§

impl<Type, Expr> Freeze for DeclareVarStmt<Type, Expr>
where Type: Freeze, Expr: Freeze,

§

impl<Type, Expr> RefUnwindSafe for DeclareVarStmt<Type, Expr>
where Type: RefUnwindSafe, Expr: RefUnwindSafe,

§

impl<Type, Expr> Send for DeclareVarStmt<Type, Expr>
where Type: Send, Expr: Send,

§

impl<Type, Expr> Sync for DeclareVarStmt<Type, Expr>
where Type: Sync, Expr: Sync,

§

impl<Type, Expr> Unpin for DeclareVarStmt<Type, Expr>
where Type: Unpin, Expr: Unpin,

§

impl<Type, Expr> UnwindSafe for DeclareVarStmt<Type, Expr>
where Type: UnwindSafe, Expr: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.