pub enum EnumToTraitStrategy {
Dynamic,
Static,
Generic,
MarkerOnly,
}Expand description
Strategy for enum-to-trait conversion
Determines how the converted type should be used:
Dynamic:Box<dyn Trait>- heap allocation, runtime polymorphismStatic:impl Traitor generics withT: Trait- monomorphization, no heapMarkerOnly: Only creates trait + structs, no type replacement
Variants§
Dynamic
Use Box<dyn Trait> for dynamic dispatch (default)
Parameters: fn process(filter: Status) → fn process(filter: Box<dyn Status>)
Return types: fn create() -> Status → fn create() -> Box<dyn Status>
Fields: filter: Status → filter: Box<dyn Status>
Static
Use impl Trait for static dispatch (functions only)
Parameters: fn process(filter: Status) → fn process(filter: impl Status)
Return types: fn create() -> Status → fn create() -> impl Status
Fields: Falls back to Box<dyn Trait> (impl Trait not allowed in fields)
Generic
Use generics <T: Trait> for full static dispatch
Structs become generic: struct Config { filter: Status } → struct Config<T: Status> { filter: T }
Functions become generic: fn process(filter: Status) → fn process<T: Status>(filter: T)
Preserves monomorphization for all cases including struct fields
MarkerOnly
Only create trait and struct definitions, no type replacement
Useful when manual control over type replacement is needed
Trait Implementations§
Source§impl Clone for EnumToTraitStrategy
impl Clone for EnumToTraitStrategy
Source§fn clone(&self) -> EnumToTraitStrategy
fn clone(&self) -> EnumToTraitStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EnumToTraitStrategy
impl Debug for EnumToTraitStrategy
Source§impl Default for EnumToTraitStrategy
impl Default for EnumToTraitStrategy
Source§fn default() -> EnumToTraitStrategy
fn default() -> EnumToTraitStrategy
Source§impl<'de> Deserialize<'de> for EnumToTraitStrategy
impl<'de> Deserialize<'de> for EnumToTraitStrategy
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EnumToTraitStrategy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EnumToTraitStrategy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for EnumToTraitStrategy
impl PartialEq for EnumToTraitStrategy
Source§fn eq(&self, other: &EnumToTraitStrategy) -> bool
fn eq(&self, other: &EnumToTraitStrategy) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for EnumToTraitStrategy
impl Serialize for EnumToTraitStrategy
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for EnumToTraitStrategy
impl Eq for EnumToTraitStrategy
impl StructuralPartialEq for EnumToTraitStrategy
Auto Trait Implementations§
impl Freeze for EnumToTraitStrategy
impl RefUnwindSafe for EnumToTraitStrategy
impl Send for EnumToTraitStrategy
impl Sync for EnumToTraitStrategy
impl Unpin for EnumToTraitStrategy
impl UnsafeUnpin for EnumToTraitStrategy
impl UnwindSafe for EnumToTraitStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more