ryo_mutations/basic/stmt/
wrap_expr.rs1use ryo_source::pure::PureExpr;
15use ryo_symbol::SymbolId;
16
17use crate::Mutation;
18
19#[derive(Debug, Clone)]
21pub struct WrapExprMutation {
22 pub target_expr: PureExpr,
24 pub wrapper_macro: String,
26 pub target_fn: SymbolId,
28 pub wrap_all: bool,
30}
31
32impl WrapExprMutation {
33 pub fn new(
34 target_expr: PureExpr,
35 wrapper_macro: impl Into<String>,
36 target_fn: SymbolId,
37 ) -> Self {
38 Self {
39 target_expr,
40 wrapper_macro: wrapper_macro.into(),
41 target_fn,
42 wrap_all: true,
43 }
44 }
45
46 pub fn first_only(mut self) -> Self {
48 self.wrap_all = false;
49 self
50 }
51}
52
53impl Mutation for WrapExprMutation {
54 fn describe(&self) -> String {
55 format!("Wrap expression with {}!()", self.wrapper_macro)
56 }
57
58 fn mutation_type(&self) -> &'static str {
59 "WrapExpr"
60 }
61
62 fn box_clone(&self) -> Box<dyn Mutation> {
63 Box::new(self.clone())
64 }
65}