pub struct ManualMapMutation {
pub target_fn: Option<SymbolId>,
}Expand description
Convert manual Option/Result mapping to .map() method
§Example
ⓘ
use ryo_mutations::idiom::ManualMapMutation;
let mutation = ManualMapMutation::new();
// Transforms:
// match opt {
// Some(x) => Some(x.to_string()),
// None => None,
// }
// Into:
// opt.map(|x| x.to_string())§Limitations
Currently only detects patterns where the AST represents Some(x) as
a Struct pattern with path “Some”. Full TupleStruct pattern support
is planned for future AST enhancements.
Fields§
§target_fn: Option<SymbolId>Target function SymbolId. If None, applies to all functions.
Implementations§
Source§impl ManualMapMutation
impl ManualMapMutation
pub fn new() -> Self
Sourcepub fn in_function(self, id: SymbolId) -> Self
pub fn in_function(self, id: SymbolId) -> Self
Only apply in a specific function
pub fn transform_block(&self, block: &mut PureBlock) -> usize
Trait Implementations§
Source§impl Clone for ManualMapMutation
impl Clone for ManualMapMutation
Source§fn clone(&self) -> ManualMapMutation
fn clone(&self) -> ManualMapMutation
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 ManualMapMutation
impl Debug for ManualMapMutation
Source§impl Default for ManualMapMutation
impl Default for ManualMapMutation
Source§fn default() -> ManualMapMutation
fn default() -> ManualMapMutation
Returns the “default value” for a type. Read more
Source§impl Mutation for ManualMapMutation
impl Mutation for ManualMapMutation
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 ManualMapMutation
impl RefUnwindSafe for ManualMapMutation
impl Send for ManualMapMutation
impl Sync for ManualMapMutation
impl Unpin for ManualMapMutation
impl UnsafeUnpin for ManualMapMutation
impl UnwindSafe for ManualMapMutation
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