use ryo_source::pure::PureExpr;
use ryo_symbol::SymbolId;
use crate::Mutation;
#[derive(Debug, Clone)]
pub struct WrapExprMutation {
pub target_expr: PureExpr,
pub wrapper_macro: String,
pub target_fn: SymbolId,
pub wrap_all: bool,
}
impl WrapExprMutation {
pub fn new(
target_expr: PureExpr,
wrapper_macro: impl Into<String>,
target_fn: SymbolId,
) -> Self {
Self {
target_expr,
wrapper_macro: wrapper_macro.into(),
target_fn,
wrap_all: true,
}
}
pub fn first_only(mut self) -> Self {
self.wrap_all = false;
self
}
}
impl Mutation for WrapExprMutation {
fn describe(&self) -> String {
format!("Wrap expression with {}!()", self.wrapper_macro)
}
fn mutation_type(&self) -> &'static str {
"WrapExpr"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}