pub trait Plugin<E: ?Sized>: Key {
type Error;
// Required method
fn eval(ext_type: &mut E) -> Result<Self::Value, Self::Error>;
}
Expand description
Implementers of this trait can act as plugins for other types, via OtherType::get<P>()
.
To create a plugin, implement this trait and provide an empty implementation
of Key
to associate the plugin with its return type, Key::Value
.
Required Associated Types§
Required Methods§
Sourcefn eval(ext_type: &mut E) -> Result<Self::Value, Self::Error>
fn eval(ext_type: &mut E) -> Result<Self::Value, Self::Error>
Create the plugin from an instance of the extended type.
While eval
is given a mutable reference to the extended
type, it is important for implementers to remember that
the result of eval
is usually cached, so care should
be taken when doing mutation on the extended type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.