ryo_mutations/idiom/
organize_imports.rs1use crate::Mutation;
11
12#[derive(Debug, Clone, Default)]
14pub struct OrganizeImportsMutation {
15 pub deduplicate: bool,
17 pub merge_groups: bool,
19}
20
21impl OrganizeImportsMutation {
22 pub fn new() -> Self {
23 Self {
24 deduplicate: true,
25 merge_groups: true,
26 }
27 }
28
29 pub fn with_deduplicate(mut self, deduplicate: bool) -> Self {
30 self.deduplicate = deduplicate;
31 self
32 }
33
34 pub fn with_merge_groups(mut self, merge: bool) -> Self {
35 self.merge_groups = merge;
36 self
37 }
38}
39
40impl Mutation for OrganizeImportsMutation {
41 fn describe(&self) -> String {
42 "Organize imports: sort and group use statements".to_string()
43 }
44
45 fn mutation_type(&self) -> &'static str {
46 "OrganizeImports"
47 }
48
49 fn box_clone(&self) -> Box<dyn Mutation> {
50 Box::new(self.clone())
51 }
52}