Skip to main content

ModuleId

Trait ModuleId 

Source
pub trait ModuleId:
    Any
    + Display
    + Send
    + Sync { }
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 LocationInModule), 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.

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ModuleId for &'static str

Implementors§