Skip to main content

ryo_mutations/basic/
use_stmt.rs

1//! Use statement mutations: AddUseMutation, RemoveUseMutation
2
3use crate::Mutation;
4
5/// Add a use statement to the file
6#[derive(Debug, Clone)]
7pub struct AddUseMutation {
8    pub path: String, // e.g., "std::collections::HashMap"
9}
10
11impl AddUseMutation {
12    pub fn new(path: impl Into<String>) -> Self {
13        Self { path: path.into() }
14    }
15}
16
17impl Mutation for AddUseMutation {
18    fn describe(&self) -> String {
19        format!("Add use {}", self.path)
20    }
21
22    fn mutation_type(&self) -> &'static str {
23        "AddUse"
24    }
25
26    fn box_clone(&self) -> Box<dyn Mutation> {
27        Box::new(self.clone())
28    }
29}
30
31/// Remove a use statement from the file
32#[derive(Debug, Clone)]
33pub struct RemoveUseMutation {
34    pub path: String,
35}
36
37impl RemoveUseMutation {
38    pub fn new(path: impl Into<String>) -> Self {
39        Self { path: path.into() }
40    }
41}
42
43impl Mutation for RemoveUseMutation {
44    fn describe(&self) -> String {
45        format!("Remove use '{}'", self.path)
46    }
47
48    fn mutation_type(&self) -> &'static str {
49        "RemoveUse"
50    }
51
52    fn box_clone(&self) -> Box<dyn Mutation> {
53        Box::new(self.clone())
54    }
55}