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

Implementations on Foreign Types§

source§

impl ModuleId for &'static str

Implementors§