use ryo_symbol::SymbolId;
use crate::Mutation;
#[derive(Debug, Clone)]
pub struct AddMatchArmMutation {
pub function_id: SymbolId,
pub enum_name: String,
pub pattern: String,
pub body: String,
}
impl AddMatchArmMutation {
pub fn new(
function_id: SymbolId,
enum_name: impl Into<String>,
pattern: impl Into<String>,
body: impl Into<String>,
) -> Self {
Self {
function_id,
enum_name: enum_name.into(),
pattern: pattern.into(),
body: body.into(),
}
}
}
impl Mutation for AddMatchArmMutation {
fn describe(&self) -> String {
format!(
"Add match arm '{}' => {} in function {}",
self.pattern, self.body, self.function_id
)
}
fn mutation_type(&self) -> &'static str {
"AddMatchArm"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}
#[derive(Debug, Clone)]
pub struct RemoveMatchArmMutation {
pub function_id: SymbolId,
pub enum_name: String,
pub pattern: String,
}
impl RemoveMatchArmMutation {
pub fn new(
function_id: SymbolId,
enum_name: impl Into<String>,
pattern: impl Into<String>,
) -> Self {
Self {
function_id,
enum_name: enum_name.into(),
pattern: pattern.into(),
}
}
}
impl Mutation for RemoveMatchArmMutation {
fn describe(&self) -> String {
format!(
"Remove match arm '{}' in function {}",
self.pattern, self.function_id
)
}
fn mutation_type(&self) -> &'static str {
"RemoveMatchArm"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}
#[derive(Debug, Clone)]
pub struct ReplaceMatchArmMutation {
pub function_id: SymbolId,
pub enum_name: String,
pub old_pattern: String,
pub new_pattern: String,
pub new_body: String,
}
impl ReplaceMatchArmMutation {
pub fn new(
function_id: SymbolId,
enum_name: impl Into<String>,
old_pattern: impl Into<String>,
new_pattern: impl Into<String>,
new_body: impl Into<String>,
) -> Self {
Self {
function_id,
enum_name: enum_name.into(),
old_pattern: old_pattern.into(),
new_pattern: new_pattern.into(),
new_body: new_body.into(),
}
}
}
impl Mutation for ReplaceMatchArmMutation {
fn describe(&self) -> String {
format!(
"Replace match arm '{}' with '{}' in function {}",
self.old_pattern, self.new_pattern, self.function_id
)
}
fn mutation_type(&self) -> &'static str {
"ReplaceMatchArm"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}