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
impl InputVariable
sourcepub fn new<Name: ToString>(name: Name) -> Self
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.
sourcepub fn value<Value: Into<MoonValue>>(self, value: Value) -> Self
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.
sourcepub fn lazy_value<Dummy, ReturnT: Into<MoonValue>, Function, AbstractFunction: ToAbstractFunction<(), ReturnT, Function, Dummy> + Clone>(
self,
function: AbstractFunction,
) -> Self
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.
sourcepub fn associated_type<'input, Name: Into<MoonValueKind<'input>>>(
self,
name: Name,
) -> Self
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.
sourcepub fn associated_type_of<T>(self) -> Self
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
impl Clone for InputVariable
source§fn clone(&self) -> InputVariable
fn clone(&self) -> InputVariable
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for InputVariable
impl !RefUnwindSafe for InputVariable
impl Send for InputVariable
impl Sync for InputVariable
impl Unpin for InputVariable
impl !UnwindSafe for InputVariable
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)