Struct rhai::Module

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

A module which may contain variables, sub-modules, external Rust functions, and/or script-defined functions.

Implementations§

source§

impl Module

source

pub const fn with_capacity(_capacity: usize) -> Self

👎Deprecated since 1.12.0: use new instead

Create a new Module with a pre-sized capacity for functions.

§Deprecated

This method is deprecated. Use new instead.

This method will be removed in the next major version.

source

pub fn get_custom_type(&self, type_name: &str) -> Option<&str>

👎Deprecated since 1.16.0: use get_custom_type_display_by_name instead

Get the display name of a registered custom type.

§Deprecated

This method is deprecated. Use get_custom_type_display_by_name instead.

This method will be removed in the next major version.

source

pub fn set_fn( &mut self, name: impl Into<Identifier>, namespace: FnNamespace, _access: FnAccess, arg_names: Option<&[&str]>, arg_types: impl AsRef<[TypeId]>, func: RhaiFunc ) -> u64

👎Deprecated since 1.17.0: use the FuncRegistration API instead

Set a native Rust function into the Module, returning a u64 hash key.

If there is an existing Rust function of the same hash, it is replaced.

§Deprecated

This method is deprecated. Use the FuncRegistration API instead.

This method will be removed in the next major version.

source

pub fn set_fn_with_comments<C: AsRef<str>>( &mut self, name: impl Into<Identifier>, namespace: FnNamespace, _access: FnAccess, arg_names: Option<&[&str]>, arg_types: impl AsRef<[TypeId]>, comments: impl IntoIterator<Item = C>, func: RhaiFunc ) -> u64

👎Deprecated since 1.17.0: use the FuncRegistration API instead

(metadata) Set a native Rust function into the Module, returning a u64 hash key. Exported under the metadata feature only.

If there is an existing Rust function of the same hash, it is replaced.

§Deprecated

This method is deprecated. Use the FuncRegistration API instead.

This method will be removed in the next major version.

source

pub fn update_fn_metadata<S: Into<Identifier>>( &mut self, hash_fn: u64, arg_names: impl IntoIterator<Item = S> ) -> &mut Self

👎Deprecated since 1.17.0: use update_fn_metadata_with_comments instead

(metadata) Update the metadata (parameter names/types and return type) of a registered function. Exported under the metadata feature only.

The u64 hash is returned by the set_native_fn call.

§Deprecated

This method is deprecated. Use update_fn_metadata_with_comments instead.

This method will be removed in the next major version.

source

pub fn gen_fn_signatures(&self) -> impl Iterator<Item = String> + '_

👎Deprecated since 1.17.0: use gen_fn_signatures_with_mapper instead

(metadata) Generate signatures for all the non-private functions in the Module. Exported under the metadata feature only.

§Deprecated

This method is deprecated. Use gen_fn_signatures_with_mapper instead.

This method will be removed in the next major version.

source§

impl Module

source

pub const fn new() -> Self

Create a new Module.

§Example
let mut module = Module::new();
module.set_var("answer", 42_i64);
assert_eq!(module.get_var_value::<i64>("answer").expect("answer should exist"), 42);
source

pub fn id(&self) -> Option<&str>

Get the ID of the Module, if any.

§Example
let mut module = Module::new();
module.set_id("hello");
assert_eq!(module.id(), Some("hello"));
source

pub fn set_id(&mut self, id: impl Into<ImmutableString>) -> &mut Self

Set the ID of the Module.

If the string is empty, it is equivalent to clearing the ID.

§Example
let mut module = Module::new();
module.set_id("hello");
assert_eq!(module.id(), Some("hello"));
source

pub fn clear_id(&mut self) -> &mut Self

Clear the ID of the Module.

§Example
let mut module = Module::new();
module.set_id("hello");
assert_eq!(module.id(), Some("hello"));
module.clear_id();
assert_eq!(module.id(), None);
source

pub fn doc(&self) -> &str

Get the documentation of the Module, if any. Exported under the metadata feature only.

§Example
let mut module = Module::new();
module.set_doc("//! This is my special module.");
assert_eq!(module.doc(), "//! This is my special module.");
source

pub fn set_doc(&mut self, doc: impl Into<SmartString<LazyCompact>>) -> &mut Self

Set the documentation of the Module. Exported under the metadata feature only.

If the string is empty, it is equivalent to clearing the documentation.

§Example
let mut module = Module::new();
module.set_doc("//! This is my special module.");
assert_eq!(module.doc(), "//! This is my special module.");
source

pub fn clear_doc(&mut self) -> &mut Self

Clear the documentation of the Module.

§Example
let mut module = Module::new();
module.set_doc("//! This is my special module.");
assert_eq!(module.doc(), "//! This is my special module.");
module.clear_doc();
assert_eq!(module.doc(), "");
source

pub fn clear(&mut self)

Clear the Module.

source

pub fn set_custom_type<T>(&mut self, name: &str) -> &mut Self

Map a custom type to a friendly display name.

§Example
#[derive(Clone)]
struct TestStruct;

let name = std::any::type_name::<TestStruct>();

let mut module = Module::new();

module.set_custom_type::<TestStruct>("MyType");

assert_eq!(module.get_custom_type_display_by_name(name), Some("MyType"));
source

pub fn set_custom_type_with_comments<T>( &mut self, name: &str, comments: &[&str] ) -> &mut Self

Map a custom type to a friendly display name. Exported under the metadata feature only.

§Comments

Block doc-comments should be kept in a separate string slice.

Line doc-comments should be merged, with line-breaks, into a single string slice without a final termination line-break.

Leading white-spaces should be stripped, and each string slice always starts with the corresponding doc-comment leader: /// or /**.

Each line in non-block doc-comments should start with ///.

source

pub fn set_custom_type_raw( &mut self, type_name: impl Into<Identifier>, display_name: impl Into<Identifier> ) -> &mut Self

Map a custom type to a friendly display name.

#[derive(Clone)]
struct TestStruct;

let name = std::any::type_name::<TestStruct>();

let mut module = Module::new();

module.set_custom_type_raw(name, "MyType");

assert_eq!(module.get_custom_type_display_by_name(name), Some("MyType"));
source

pub fn set_custom_type_with_comments_raw<C: Into<SmartString<LazyCompact>>>( &mut self, type_name: impl Into<Identifier>, display_name: impl Into<Identifier>, comments: impl IntoIterator<Item = C> ) -> &mut Self

Map a custom type to a friendly display name. Exported under the metadata feature only.

§Comments

Block doc-comments should be kept in a separate string slice.

Line doc-comments should be merged, with line-breaks, into a single string slice without a final termination line-break.

Leading white-spaces should be stripped, and each string slice always starts with the corresponding doc-comment leader: /// or /**.

Each line in non-block doc-comments should start with ///.

source

pub fn get_custom_type_display_by_name(&self, type_name: &str) -> Option<&str>

Get the display name of a registered custom type.

§Example
#[derive(Clone)]
struct TestStruct;

let name = std::any::type_name::<TestStruct>();

let mut module = Module::new();

module.set_custom_type::<TestStruct>("MyType");

assert_eq!(module.get_custom_type_display_by_name(name), Some("MyType"));
source

pub fn get_custom_type_display<T>(&self) -> Option<&str>

Get the display name of a registered custom type.

§Example
#[derive(Clone)]
struct TestStruct;

let name = std::any::type_name::<TestStruct>();

let mut module = Module::new();

module.set_custom_type::<TestStruct>("MyType");

assert_eq!(module.get_custom_type_display::<TestStruct>(), Some("MyType"));
source

pub fn get_custom_type_raw<T>(&self) -> Option<&CustomTypeInfo>

(internals) Get a registered custom type . Exported under the internals feature only.

source

pub fn get_custom_type_by_name_raw( &self, type_name: &str ) -> Option<&CustomTypeInfo>

(internals) Get a registered custom type by its type name. Exported under the internals feature only.

source

pub fn is_empty(&self) -> bool

Returns true if this Module contains no items.

§Example
let module = Module::new();
assert!(module.is_empty());
source

pub const fn is_indexed(&self) -> bool

Is the Module indexed?

A module must be indexed before it can be used in an import statement.

§Example
let mut module = Module::new();
assert!(module.is_indexed());

module.set_native_fn("foo", |x: &mut i64, y: i64| { *x = y; Ok(()) });
assert!(!module.is_indexed());

module.build_index();
assert!(module.is_indexed());
source

pub const fn is_internal(&self) -> bool

Is the Module an internal Rhai system module?

source

pub const fn is_standard_lib(&self) -> bool

Is the Module a Rhai standard library module?

source

pub fn gen_fn_signatures_with_mapper<'a>( &'a self, type_mapper: impl Fn(&'a str) -> Cow<'a, str> + 'a ) -> impl Iterator<Item = String> + 'a

(metadata) Generate signatures for all the non-private functions in the Module. Exported under the metadata feature only.

source

pub fn contains_var(&self, name: &str) -> bool

Does a variable exist in the Module?

§Example
let mut module = Module::new();
module.set_var("answer", 42_i64);
assert!(module.contains_var("answer"));
source

pub fn get_var_value<T: Variant + Clone>(&self, name: &str) -> Option<T>

Get the value of a Module variable.

§Example
let mut module = Module::new();
module.set_var("answer", 42_i64);
assert_eq!(module.get_var_value::<i64>("answer").expect("answer should exist"), 42);
source

pub fn get_var(&self, name: &str) -> Option<Dynamic>

Get a Module variable as a Dynamic.

§Example
let mut module = Module::new();
module.set_var("answer", 42_i64);
assert_eq!(module.get_var("answer").expect("answer should exist").cast::<i64>(), 42);
source

pub fn set_var( &mut self, name: impl Into<Identifier>, value: impl Variant + Clone ) -> &mut Self

Set a variable into the Module.

If there is an existing variable of the same name, it is replaced.

§Example
let mut module = Module::new();
module.set_var("answer", 42_i64);
assert_eq!(module.get_var_value::<i64>("answer").expect("answer should exist"), 42);
source

pub fn set_script_fn(&mut self, fn_def: impl Into<Shared<ScriptFuncDef>>) -> u64

Set a script-defined function into the Module.

If there is an existing function of the same name and number of arguments, it is replaced.

source

pub fn get_script_fn( &self, name: impl AsRef<str>, num_params: usize ) -> Option<&Shared<ScriptFuncDef>>

Get a shared reference to the script-defined function in the Module based on name and number of parameters.

source

pub fn contains_sub_module(&self, name: &str) -> bool

Does a sub-module exist in the Module?

§Example
let mut module = Module::new();
let sub_module = Module::new();
module.set_sub_module("question", sub_module);
assert!(module.contains_sub_module("question"));
source

pub fn get_sub_module(&self, name: &str) -> Option<&Self>

Get a sub-module in the Module.

§Example
let mut module = Module::new();
let sub_module = Module::new();
module.set_sub_module("question", sub_module);
assert!(module.get_sub_module("question").is_some());
source

pub fn set_sub_module( &mut self, name: impl Into<Identifier>, sub_module: impl Into<Shared<Module>> ) -> &mut Self

Set a sub-module into the Module.

If there is an existing sub-module of the same name, it is replaced.

§Example
let mut module = Module::new();
let sub_module = Module::new();
module.set_sub_module("question", sub_module);
assert!(module.get_sub_module("question").is_some());
source

pub fn contains_fn(&self, hash_fn: u64) -> bool

Does the particular Rust function exist in the Module?

The u64 hash is returned by the set_native_fn call.

§Example
let mut module = Module::new();
let hash = module.set_native_fn("calc", |x: i64| Ok(42 + x));
assert!(module.contains_fn(hash));
source

pub fn update_fn_metadata_with_comments<A: Into<Identifier>, C: Into<SmartString<LazyCompact>>>( &mut self, hash_fn: u64, arg_names: impl IntoIterator<Item = A>, comments: impl IntoIterator<Item = C> ) -> &mut Self

👎Deprecated since 1.17.0: use the FuncRegistration API instead

(metadata) Update the metadata (parameter names/types, return type and doc-comments) of a registered function. Exported under the metadata feature only.

§Deprecated

This method is deprecated. Use the FuncRegistration API instead.

This method will be removed in the next major version.

source

pub fn update_fn_namespace( &mut self, hash_fn: u64, namespace: FnNamespace ) -> &mut Self

👎Deprecated since 1.17.0: use the FuncRegistration API instead

Update the namespace of a registered function.

§Deprecated

This method is deprecated. Use the FuncRegistration API instead.

This method will be removed in the next major version.

source

pub fn set_fn_raw_with_options( &mut self, options: FuncRegistration, arg_types: impl AsRef<[TypeId]>, func: RhaiFunc ) -> &FuncMetadata

Set a native Rust function into the Module based on a FuncRegistration.

§WARNING - Low Level API

This function is very low level. It takes a list of TypeId’s indicating the actual types of the parameters.

source

pub fn set_native_fn<A: 'static, const N: usize, const X: bool, R, FUNC>( &mut self, name: impl Into<Identifier>, func: FUNC ) -> u64
where R: Variant + Clone, FUNC: RhaiNativeFunc<A, N, X, R, true> + SendSync + 'static,

Set a native Rust function into the Module, returning a u64 hash key.

If there is a similar existing Rust function, it is replaced.

§Use FuncRegistration API

It is recommended that the FuncRegistration API be used instead.

Essentially, this method is a shortcut for:

FuncRegistration::new(name)
    .in_internal_namespace()
    .with_purity(true)
    .with_volatility(false)
    .set_into_module(module, func)
    .hash
§Assumptions
  • Accessibility: The function namespace is FnNamespace::Internal.

  • Purity: The function is assumed to be pure unless it is a property setter or an index setter.

  • Volatility: The function is assumed to be non-volatile – i.e. it guarantees the same result for the same input(s).

  • Metadata: No metadata for the function is registered.

To change these assumptions, use the FuncRegistration API instead.

§Example
let mut module = Module::new();
let hash = module.set_native_fn("calc", |x: i64| Ok(42 + x));
assert!(module.contains_fn(hash));
source

pub fn set_getter_fn<A, const X: bool, R, FUNC>( &mut self, name: impl AsRef<str>, func: FUNC ) -> u64
where A: Variant + Clone, R: Variant + Clone, FUNC: RhaiNativeFunc<(Mut<A>,), 1, X, R, true> + SendSync + 'static,

Set a Rust getter function taking one mutable parameter, returning a u64 hash key. This function is automatically exposed to the global namespace.

If there is a similar existing Rust getter function, it is replaced.

§Assumptions
  • Accessibility: The function namespace is FnNamespace::Global.

  • Purity: The function is assumed to be pure (so it can be called on constants).

  • Volatility: The function is assumed to be non-volatile – i.e. it guarantees the same result for the same input(s).

  • Metadata: No metadata for the function is registered.

To change these assumptions, use the FuncRegistration API instead.

§Example
let mut module = Module::new();
let hash = module.set_getter_fn("value", |x: &mut i64| Ok(*x));
assert!(module.contains_fn(hash));
source

pub fn set_setter_fn<A, const X: bool, R, FUNC>( &mut self, name: impl AsRef<str>, func: FUNC ) -> u64
where A: Variant + Clone, R: Variant + Clone, FUNC: RhaiNativeFunc<(Mut<A>, R), 2, X, (), true> + SendSync + 'static,

Set a Rust setter function taking two parameters (the first one mutable) into the Module, returning a u64 hash key. This function is automatically exposed to the global namespace.

If there is a similar existing setter Rust function, it is replaced.

§Assumptions
  • Accessibility: The function namespace is FnNamespace::Global.

  • Purity: The function is assumed to be non-pure (so it cannot be called on constants).

  • Volatility: The function is assumed to be non-volatile – i.e. it guarantees the same result for the same input(s).

  • Metadata: No metadata for the function is registered.

To change these assumptions, use the FuncRegistration API instead.

§Example
use rhai::{Module, ImmutableString};

let mut module = Module::new();
let hash = module.set_setter_fn("value", |x: &mut i64, y: ImmutableString| {
                *x = y.len() as i64; Ok(())
});
assert!(module.contains_fn(hash));
source

pub fn set_getter_setter_fn<A: Variant + Clone, const X1: bool, const X2: bool, R: Variant + Clone>( &mut self, name: impl AsRef<str>, getter: impl RhaiNativeFunc<(Mut<A>,), 1, X1, R, true> + SendSync + 'static, setter: impl RhaiNativeFunc<(Mut<A>, R), 2, X2, (), true> + SendSync + 'static ) -> (u64, u64)

Set a pair of Rust getter and setter functions into the Module, returning both u64 hash keys. This is a short-hand for set_getter_fn and set_setter_fn.

These function are automatically exposed to the global namespace.

If there are similar existing Rust functions, they are replaced.

To change these assumptions, use the FuncRegistration API instead.

§Example
use rhai::{Module, ImmutableString};

let mut module = Module::new();
let (hash_get, hash_set) =
        module.set_getter_setter_fn("value",
                |x: &mut i64| Ok(x.to_string().into()),
                |x: &mut i64, y: ImmutableString| { *x = y.len() as i64; Ok(()) }
        );
assert!(module.contains_fn(hash_get));
assert!(module.contains_fn(hash_set));
source

pub fn set_indexer_get_fn<A, B, const X: bool, R, FUNC>( &mut self, func: FUNC ) -> u64
where A: Variant + Clone, B: Variant + Clone, R: Variant + Clone, FUNC: RhaiNativeFunc<(Mut<A>, B), 2, X, R, true> + SendSync + 'static,

Set a Rust index getter taking two parameters (the first one mutable) into the Module, returning a u64 hash key. This function is automatically exposed to the global namespace.

If there is a similar existing setter Rust function, it is replaced.

§Assumptions
  • Accessibility: The function namespace is FnNamespace::Global.

  • Purity: The function is assumed to be pure (so it can be called on constants).

  • Volatility: The function is assumed to be non-volatile – i.e. it guarantees the same result for the same input(s).

  • Metadata: No metadata for the function is registered.

To change these assumptions, use the FuncRegistration API instead.

§Panics

Panics if the type is Array, Map, String, ImmutableString, &str or INT.

Indexers for arrays, object maps, strings and integers cannot be registered.

§Example
use rhai::{Module, ImmutableString};

#[derive(Clone)]
struct TestStruct(i64);

let mut module = Module::new();

let hash = module.set_indexer_get_fn(
                |x: &mut TestStruct, y: ImmutableString| Ok(x.0 + y.len() as i64)
           );

assert!(module.contains_fn(hash));
source

pub fn set_indexer_set_fn<A, B, const X: bool, R, FUNC>( &mut self, func: FUNC ) -> u64
where A: Variant + Clone, B: Variant + Clone, R: Variant + Clone, FUNC: RhaiNativeFunc<(Mut<A>, B, R), 3, X, (), true> + SendSync + 'static,

Set a Rust index setter taking three parameters (the first one mutable) into the Module, returning a u64 hash key. This function is automatically exposed to the global namespace.

If there is a similar existing Rust function, it is replaced.

§Assumptions
  • Accessibility: The function namespace is FnNamespace::Global.

  • Purity: The function is assumed to be non-pure (so it cannot be called on constants).

  • Volatility: The function is assumed to be non-volatile – i.e. it guarantees the same result for the same input(s).

§Panics

Panics if the type is Array, Map, String, ImmutableString, &str or INT.

Indexers for arrays, object maps, strings and integers cannot be registered.

§Example
use rhai::{Module, ImmutableString};

#[derive(Clone)]
struct TestStruct(i64);

let mut module = Module::new();

let hash = module.set_indexer_set_fn(|x: &mut TestStruct, y: ImmutableString, value: i64| {
                        *x = TestStruct(y.len() as i64 + value);
                        Ok(())
           });

assert!(module.contains_fn(hash));
source

pub fn set_indexer_get_set_fn<A: Variant + Clone, B: Variant + Clone, const X1: bool, const X2: bool, R: Variant + Clone>( &mut self, get_fn: impl RhaiNativeFunc<(Mut<A>, B), 2, X1, R, true> + SendSync + 'static, set_fn: impl RhaiNativeFunc<(Mut<A>, B, R), 3, X2, (), true> + SendSync + 'static ) -> (u64, u64)

Set a pair of Rust index getter and setter functions into the Module, returning both u64 hash keys. This is a short-hand for set_indexer_get_fn and set_indexer_set_fn.

These functions are automatically exposed to the global namespace.

If there are similar existing Rust functions, they are replaced.

§Panics

Panics if the type is Array, Map, String, ImmutableString, &str or INT.

Indexers for arrays, object maps, strings and integers cannot be registered.

§Example
use rhai::{Module, ImmutableString};

#[derive(Clone)]
struct TestStruct(i64);

let mut module = Module::new();

let (hash_get, hash_set) = module.set_indexer_get_set_fn(
    |x: &mut TestStruct, y: ImmutableString| Ok(x.0 + y.len() as i64),
    |x: &mut TestStruct, y: ImmutableString, value: i64| { *x = TestStruct(y.len() as i64 + value); Ok(()) }
);

assert!(module.contains_fn(hash_get));
assert!(module.contains_fn(hash_set));
source

pub fn contains_qualified_fn(&self, hash_fn: u64) -> bool

Does the particular namespace-qualified function exist in the Module?

The u64 hash is calculated by build_index.

source

pub fn combine(&mut self, other: Self) -> &mut Self

Combine another Module into this Module. The other Module is consumed to merge into this Module.

source

pub fn combine_flatten(&mut self, other: Self) -> &mut Self

Combine another Module into this Module. The other Module is consumed to merge into this Module. Sub-modules are flattened onto the root Module, with higher level overriding lower level.

source

pub fn fill_with(&mut self, other: &Self) -> &mut Self

Polyfill this Module with another Module. Only items not existing in this Module are added.

source

pub fn merge(&mut self, other: &Self) -> &mut Self

Merge another Module into this Module.

source

pub fn count(&self) -> (usize, usize, usize)

Get the number of variables, functions and type iterators in the Module.

source

pub fn iter_sub_modules(&self) -> impl Iterator<Item = (&str, &Shared<Module>)>

Get an iterator to the sub-modules in the Module.

source

pub fn iter_var(&self) -> impl Iterator<Item = (&str, &Dynamic)>

Get an iterator to the variables in the Module.

source

pub fn iter_script_fn_info( &self ) -> impl Iterator<Item = (FnNamespace, FnAccess, &str, usize, &Shared<ScriptFuncDef>)>

(internals) Get an iterator over all script-defined functions in the Module. Exported under the internals feature only.

Function metadata includes:

  1. Namespace (FnNamespace::Global or FnNamespace::Internal).
  2. Access mode (FnAccess::Public or FnAccess::Private).
  3. Function name (as string slice).
  4. Number of parameters.
  5. (internals) Shared reference to function definition ScriptFuncDef.
source

pub fn eval_ast_as_new( scope: Scope<'_>, ast: &AST, engine: &Engine ) -> Result<Self, Box<EvalAltResult>>

Create a new Module by evaluating an AST.

The entire AST is encapsulated into each function, allowing functions to cross-call each other.

§Example
use rhai::{Engine, Module, Scope};

let engine = Engine::new();
let ast = engine.compile("let answer = 42; export answer;")?;
let module = Module::eval_ast_as_new(Scope::new(), &ast, &engine)?;
assert!(module.contains_var("answer"));
assert_eq!(module.get_var_value::<i64>("answer").expect("answer should exist"), 42);
source

pub fn eval_ast_as_new_raw( engine: &Engine, scope: &mut Scope<'_>, global: &mut GlobalRuntimeState, ast: &AST ) -> Result<Self, Box<EvalAltResult>>

Create a new Module by evaluating an AST.

The entire AST is encapsulated into each function, allowing functions to cross-call each other.

§WARNING - Low Level API

This function is very low level.

In particular, the global parameter allows the entire calling environment to be encapsulated, including automatic global constants.

source

pub const fn contains_indexed_global_functions(&self) -> bool

Does the Module contain indexed functions that have been exposed to the global namespace?

§Panics

Panics if the Module is not yet indexed via build_index.

source

pub fn build_index(&mut self) -> &mut Self

Scan through all the sub-modules in the Module and build a hash index of all variables and functions as one flattened namespace.

If the Module is already indexed, this method has no effect.

source

pub fn contains_qualified_iter(&self, id: TypeId) -> bool

Does a type iterator exist in the entire module tree?

source

pub fn contains_iter(&self, id: TypeId) -> bool

Does a type iterator exist in the module?

source

pub fn set_iter( &mut self, type_id: TypeId, func: impl Fn(Dynamic) -> Box<dyn Iterator<Item = Dynamic>> + SendSync + 'static ) -> &mut Self

Set a type iterator into the Module.

source

pub fn set_iter_result( &mut self, type_id: TypeId, func: impl Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>> + SendSync + 'static ) -> &mut Self

Set a fallible type iterator into the Module.

source

pub fn set_iterable<T>(&mut self) -> &mut Self

Set a type iterator into the Module.

source

pub fn set_iterable_result<T, X>(&mut self) -> &mut Self
where T: Variant + Clone + IntoIterator<Item = Result<X, Box<EvalAltResult>>>, X: Variant + Clone,

Set a fallible type iterator into the Module.

source

pub fn set_iterator<T>(&mut self) -> &mut Self
where T: Variant + Clone + Iterator, <T as Iterator>::Item: Variant + Clone,

Set an iterator type into the Module as a type iterator.

source

pub fn set_iterator_result<T, X>(&mut self) -> &mut Self
where T: Variant + Clone + Iterator<Item = Result<X, Box<EvalAltResult>>>, X: Variant + Clone,

Set a iterator type into the Module as a fallible type iterator.

Trait Implementations§

source§

impl<M: AsRef<Module>> Add<M> for &Module

§

type Output = Module

The resulting type after applying the + operator.
source§

fn add(self, rhs: M) -> Self::Output

Performs the + operation. Read more
source§

impl<M: AsRef<Self>> Add<M> for Module

§

type Output = Module

The resulting type after applying the + operator.
source§

fn add(self, rhs: M) -> Self::Output

Performs the + operation. Read more
source§

impl<M: Into<Self>> AddAssign<M> for Module

source§

fn add_assign(&mut self, rhs: M)

Performs the += operation. Read more
source§

impl AsRef<Module> for AST

source§

fn as_ref(&self) -> &Module

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<Module> for AST

source§

fn borrow(&self) -> &Module

Immutably borrows from an owned value. Read more
source§

impl Clone for Module

source§

fn clone(&self) -> Module

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 Module

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Module

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: Into<Shared<ScriptFuncDef>>> Extend<T> for Module

source§

fn extend<ITER: IntoIterator<Item = T>>(&mut self, iter: ITER)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<T: IntoIterator<Item = Shared<ScriptFuncDef>>> From<T> for Module

source§

fn from(iter: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Module

§

impl !RefUnwindSafe for Module

§

impl !Send for Module

§

impl !Sync for Module

§

impl Unpin for Module

§

impl !UnwindSafe for Module

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

§

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>,

§

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>,

§

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.
source§

impl<T> Variant for T
where T: Any + Clone + SendSync,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert this Variant trait object to &dyn Any.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert this Variant trait object to &mut dyn Any.
source§

fn as_boxed_any(self: Box<T>) -> Box<dyn Any>

Convert this Variant trait object to Box<dyn Any>.
source§

fn type_name(&self) -> &'static str

Get the name of this type.
source§

fn clone_object(&self) -> Box<dyn Variant>

Clone this Variant trait object.