Trait ModuleId

Source
pub trait ModuleId:
    Any
    + Display
    + Send
    + Sync {
    // Required method
    fn clone_boxed(&self) -> Box<dyn ModuleId>;
}
Expand description

Identifier of an ExecutableModule. This is usually a “small” type, such as an integer or a string.

The ID is provided when creating a module. It is displayed in error messages (using Display::fmt). ModuleId is also associated with some types (e.g., InterpretedFn and CodeInModule), which allows to obtain module info. This can be particularly useful for outputting rich error information.

A ModuleId can be downcast to a specific type, similarly to Any.

Required Methods§

Source

fn clone_boxed(&self) -> Box<dyn ModuleId>

Clones this module ID and boxes the result. It is expected that the output will have the same specific type as the original module ID. This operation is generally expected to be quite cheap.

Implementations§

Source§

impl dyn ModuleId

Source

pub fn is<T: ModuleId>(&self) -> bool

Returns true if the boxed type is the same as T.

This method is effectively a carbon copy of <dyn Any>::is. Such a copy is necessary because &dyn ModuleId cannot be converted to &dyn Any, despite ModuleId having Any as a super-trait.

Source

pub fn downcast_ref<T: ModuleId>(&self) -> Option<&T>

Returns a reference to the boxed value if it is of type T, or None if it isn’t.

This method is effectively a carbon copy of <dyn Any>::downcast_ref. Such a copy is necessary because &dyn ModuleId cannot be converted to &dyn Any, despite ModuleId having Any as a super-trait.

Trait Implementations§

Source§

impl Debug for dyn ModuleId

Source§

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

Formats the value using the given formatter. Read more

Implementations on Foreign Types§

Source§

impl ModuleId for &'static str

Source§

fn clone_boxed(&self) -> Box<dyn ModuleId>

Implementors§