Expand description
§disponent
An alternative to dyn Trait for dispatching to multiple implementations.
§Example
Use the declare! macro to define a trait and enum together. The enum will
implement the trait by delegating method calls to its variants.
use disponent::declare;
declare!(
pub enum FooOrBar {
Foo(Foo),
Bar(Bar),
}
pub trait SayHello {
fn say_hello(&self);
}
);§Configuration
Use #[disponent::configure(...)] on the enum with:
inherent: Generate inherent methods (vs trait impl)inline: Add#[inline]to methodsfrom: GenerateFrom<T> for Enumimplstry_into: GenerateTryInto<T> for Enumimpls
§Remote Traits
Use #[disponent::remote(...)] on the trait to implement a trait defined elsewhere.
Macros§
- declare
- Declare a trait and enum together, generating forwarding methods.