pub struct DeriveDefaultMutation {
pub target_type: Option<String>,
}Expand description
Convert manual Default implementations to #[derive(Default)]
This mutation:
- Finds
impl Default for Tblocks - Checks if all field initializations use default values
- Removes the impl block
- Adds
#[derive(Default)]to the struct
§Example
ⓘ
use ryo_mutations::idiom::DeriveDefaultMutation;
let mutation = DeriveDefaultMutation::new();
let result = mutation.apply(&mut file);Fields§
§target_type: Option<String>Only apply to specific type
Implementations§
Trait Implementations§
Source§impl Clone for DeriveDefaultMutation
impl Clone for DeriveDefaultMutation
Source§fn clone(&self) -> DeriveDefaultMutation
fn clone(&self) -> DeriveDefaultMutation
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 DeriveDefaultMutation
impl Debug for DeriveDefaultMutation
Source§impl Default for DeriveDefaultMutation
impl Default for DeriveDefaultMutation
Source§fn default() -> DeriveDefaultMutation
fn default() -> DeriveDefaultMutation
Returns the “default value” for a type. Read more
Source§impl Detect for DeriveDefaultMutation
impl Detect for DeriveDefaultMutation
Source§fn category(&self) -> DetectCategory
fn category(&self) -> DetectCategory
Get the category for detected opportunities
Source§fn detect_name(&self) -> &'static str
fn detect_name(&self) -> &'static str
Get the mutation/pattern name
Source§fn detect_description(&self) -> &str
fn detect_description(&self) -> &str
Get description
Source§impl Mutation for DeriveDefaultMutation
impl Mutation for DeriveDefaultMutation
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 DeriveDefaultMutation
impl RefUnwindSafe for DeriveDefaultMutation
impl Send for DeriveDefaultMutation
impl Sync for DeriveDefaultMutation
impl Unpin for DeriveDefaultMutation
impl UnsafeUnpin for DeriveDefaultMutation
impl UnwindSafe for DeriveDefaultMutation
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