Struct ModuleBuilder

Source
pub struct ModuleBuilder { /* private fields */ }
Expand description

Helper to build modules in Rust code.

Implementations§

Source§

impl ModuleBuilder

Source

pub fn new(name: &str, scope: Scope) -> ModuleBuilder

Creates a new ModuleBuilder for the given scope.

Source

pub fn add_constant<T: Into<Value>>(self, name: &str, value: T) -> Self

Adds a constant value to the module.

Source

pub fn add_doc(self, name: &str, doc: &str) -> Self

Adds a documentation string for the given name.

Source

pub fn add_function( self, name: &str, callback: FunctionImpl, arity: Arity, doc: Option<&'static str>, ) -> Self

Adds a function to the module.

Source

pub fn add_value(self, name: &str, value: Value) -> Self

Adds a value to the module.

Source

pub fn add_value_with_name<F>(self, name: &str, f: F) -> Self
where F: FnOnce(Name) -> Value,

Adds a value to the module using the generated name value.

Source

pub fn finish(self) -> Module

Consumes the builder and returns the new Module.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V