pub struct EnumToTraitMutation {
pub symbol_id: SymbolId,
pub trait_name: Option<String>,
pub remove_enum: bool,
pub variants: Vec<VariantInfo>,
pub strategy: EnumToTraitStrategy,
pub match_handling: MatchHandling,
}Expand description
Convert an enum to a trait with struct implementations
Transforms:
ⓘ
enum Status {
Running,
Stopped,
}Into:
ⓘ
pub trait Status {}
pub struct Running;
pub struct Stopped;
impl Status for Running {}
impl Status for Stopped {}Also replaces all usage sites: Status::Running → Running
§Type Replacement Strategy
With strategy: Dynamic (default):
ⓘ
fn process(status: Status) → fn process(status: Box<dyn Status>)With strategy: Static:
ⓘ
fn process(status: Status) → fn process(status: impl Status)With strategy: MarkerOnly: No type replacement (manual migration)
Note: Uses symbol_id for reliable O(1) enum identification.
Fields§
§symbol_id: SymbolIdSymbolId of the target enum (required for reliable identification)
trait_name: Option<String>Custom trait name (None = same as enum name)
remove_enum: boolWhether to remove the original enum
variants: Vec<VariantInfo>Variant info (populated during apply from AST)
strategy: EnumToTraitStrategyStrategy for type replacement (default: Dynamic)
match_handling: MatchHandlingHow to handle match expressions (default: WarnOnly)
Implementations§
Source§impl EnumToTraitMutation
impl EnumToTraitMutation
Sourcepub fn from_symbol_id(symbol_id: SymbolId) -> Self
pub fn from_symbol_id(symbol_id: SymbolId) -> Self
Create from SymbolId (required for reliable enum identification)
pub fn with_trait_name(self, name: impl Into<String>) -> Self
pub fn keep_enum(self) -> Self
pub fn with_variants(self, variants: Vec<VariantInfo>) -> Self
Sourcepub fn with_strategy(self, strategy: EnumToTraitStrategy) -> Self
pub fn with_strategy(self, strategy: EnumToTraitStrategy) -> Self
Set the type replacement strategy
Sourcepub fn with_match_handling(self, handling: MatchHandling) -> Self
pub fn with_match_handling(self, handling: MatchHandling) -> Self
Set how match expressions should be handled
Trait Implementations§
Source§impl Clone for EnumToTraitMutation
impl Clone for EnumToTraitMutation
Source§fn clone(&self) -> EnumToTraitMutation
fn clone(&self) -> EnumToTraitMutation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EnumToTraitMutation
impl Debug for EnumToTraitMutation
Source§impl Mutation for EnumToTraitMutation
impl Mutation for EnumToTraitMutation
Source§fn mutation_type(&self) -> &'static str
fn mutation_type(&self) -> &'static str
Get the mutation type name
Source§fn validate(&self, _file: &PureFile) -> ValidationResult
fn validate(&self, _file: &PureFile) -> ValidationResult
Validate the mutation before applying Read more
Source§fn can_proceed(&self, file: &PureFile, strategy: ValidationStrategy) -> bool
fn can_proceed(&self, file: &PureFile, strategy: ValidationStrategy) -> bool
Check if this mutation can proceed with the given strategy
Auto Trait Implementations§
impl Freeze for EnumToTraitMutation
impl RefUnwindSafe for EnumToTraitMutation
impl Send for EnumToTraitMutation
impl Sync for EnumToTraitMutation
impl Unpin for EnumToTraitMutation
impl UnsafeUnpin for EnumToTraitMutation
impl UnwindSafe for EnumToTraitMutation
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
Mutably borrows from an owned value. Read more