Struct moon_script::engine::context::InputVariable

source ·
pub struct InputVariable { /* private fields */ }
Expand description

Holds information about a variable that can be given to a crate::ContextBuilder as a means of inputs.

Implementations§

source§

impl InputVariable

source

pub fn new<Name: ToString>(name: Name) -> Self

Creates a new variable as a place-holder with a name, if it’s value is indicated with Self::value, it will turn into a constant variable, where it’s value can be inlined when compiling an AST, the value can also be given with Self::lazy_value as part of a context, but if the value isn’t given in none of these ways and its used in the script, you should give this value to the AST’s executor thorough crate::ASTExecutor::push_variable or crate::OptimizedASTExecutor::push_variable.

source

pub fn value<Value: Into<MoonValue>>(self, value: Value) -> Self

Specifies the value of this variable, this means it turns into a constant variable, and therefore it can be inlined when parsing an AST.

source

pub fn lazy_value<Dummy, ReturnT: Into<MoonValue>, Function, AbstractFunction: ToAbstractFunction<(), ReturnT, Function, Dummy> + Clone>( self, function: AbstractFunction, ) -> Self

Specifies a function that gives the value of this variable, the difference between this and given it’s value to the AST’s executor is just performance, as crate::ASTExecutor::push_variable it’s slower due to the need of checking a HashMap.

source

pub fn associated_type<'input, Name: Into<MoonValueKind<'input>>>( self, name: Name, ) -> Self

Specifies what kind type is associated to this variable, see the Properties section of the book for more information about properties.

source

pub fn associated_type_of<T>(self) -> Self

Specifies what kind type is associated to this variable, but instead of receiving a name or a crate::MoonValueKind, it receives the value’s type, this is preferred over Self::associated_type but it doesn’t allow you to create pseudo-types, requiring the use of real types.

see the Properties section of the book for more information about properties.

Trait Implementations§

source§

impl Clone for InputVariable

source§

fn clone(&self) -> InputVariable

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for InputVariable

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.