ryo-mutations 0.1.0

[experimental] Code transformation primitives for Rust source code
Documentation
//! Idiomatic Rust transformations
//!
//! Mechanical transformations between equivalent Rust constructs.
//! These are safe, behavior-preserving changes that improve code style.
//!
//! # Clippy Integration
//!
//! Many of these mutations correspond to Clippy lints and can be automatically
//! triggered via the [`crate::clippy`] module. See the clippy module
//! documentation for the full mapping.
//!
//! # Categories
//!
//! ## Tier 1: High-frequency Clippy lints
//!
//! | Mutation | Clippy Lint | Description |
//! |----------|-------------|-------------|
//! | [`BoolSimplifyMutation`] | `bool_comparison` | `x == true` → `x` |
//! | [`CollapsibleIfMutation`] | `collapsible_if` | Merge nested if statements |
//! | [`ComparisonToMethodMutation`] | `comparison_to_empty` | `s == ""` → `s.is_empty()` |
//! | [`AssignOpMutation`] | `assign_op_pattern` | `a = a + b` → `a += b` |
//! | [`CloneOnCopyMutation`] | `clone_on_copy` | Remove `.clone()` on Copy types |
//! | [`RedundantClosureMutation`] | `redundant_closure` | `\|x\| f(x)` → `f` |
//! | [`FilterNextMutation`] | `filter_next` | `.filter().next()` → `.find()` |
//! | [`MapUnwrapOrMutation`] | `map_unwrap_or` | `.map().unwrap_or()` → `.map_or()` |
//!
//! ## Tier 2: Pattern transformations
//!
//! | Mutation | Description |
//! |----------|-------------|
//! | [`ManualMapMutation`] | `match opt { Some(x) => Some(f(x)), None => None }` → `opt.map(f)` |
//! | [`LoopToIteratorMutation`] | `for x in iter { v.push(f(x)) }` → `iter.map(f).collect()` |
//! | [`UnwrapToQuestionMutation`] | `.unwrap()` → `?` in functions returning Result/Option |
//!
//! ## Tier 3: Code generation (Design patterns)
//!
//! | Mutation | Description |
//! |----------|-------------|
//! | [`DefaultMutation`] | Add Default impl to structs |
//! | [`DeriveDefaultMutation`] | Convert manual impl Default to derive |
//!
//! ## Tier 4: Performance/Safety
//!
//! | Mutation | Description |
//! |----------|-------------|
//! | [`UseAtomicMutation`] | Suggest Mutex → Atomic for simple fields |
//! | [`UseRwLockMutation`] | Suggest Mutex → RwLock for read-heavy access |
//! | [`LockScopeMutation`] | Detect locks held across await points |
//!
//! ## Utilities
//!
//! | Mutation | Description |
//! |----------|-------------|
//! | [`OrganizeImportsMutation`] | Sort and group use statements |
//! | [`IntroduceVariableMutation`] | Extract repeated expressions into variables |
//! | [`MatchToIfLetMutation`] | Convert simple match to if let |

mod assign_op;
mod bool_simplify;
mod clone_on_copy;
mod collapsible_if;
mod comparison_to_method;
mod default;
pub mod detect;
mod filter_next;
mod introduce_variable;
mod lock;
mod loop_to_iter;
mod manual_map;
mod map_unwrap_or;
mod match_to_if_let;
mod noop_arm;
mod organize_imports;
mod redundant_closure;
mod unwrap_to_question;

// Tier 1: Clippy high-frequency lints
pub use assign_op::AssignOpMutation;
pub use bool_simplify::BoolSimplifyMutation;
pub use clone_on_copy::CloneOnCopyMutation;
pub use collapsible_if::CollapsibleIfMutation;
pub use comparison_to_method::ComparisonToMethodMutation;
pub use filter_next::FilterNextMutation;
pub use map_unwrap_or::MapUnwrapOrMutation;
pub use noop_arm::NoOpArmToTodoMutation;
pub use redundant_closure::RedundantClosureMutation;

// Tier 2: Pattern transformations
pub use introduce_variable::{FindDuplicateExpressions, IntroduceVariableMutation};
pub use loop_to_iter::{LoopPattern, LoopToIteratorMutation};
pub use manual_map::ManualMapMutation;
pub use match_to_if_let::MatchToIfLetMutation;
pub use organize_imports::OrganizeImportsMutation;
pub use unwrap_to_question::UnwrapToQuestionMutation;

// Tier 3: Code generation (Design patterns)
pub use default::{DefaultMutation, DeriveDefaultMutation};

// Tier 4: Performance/Safety
pub use lock::{LockScopeMutation, UseAtomicMutation, UseRwLockMutation};