use ryo_symbol::SymbolId;
use crate::Mutation;
#[derive(Debug, Clone)]
pub struct AddDeriveMutation {
pub symbol_id: SymbolId,
pub derives: Vec<String>,
}
impl AddDeriveMutation {
pub fn new(symbol_id: SymbolId, derives: Vec<String>) -> Self {
Self { symbol_id, derives }
}
pub fn single(symbol_id: SymbolId, derive: impl Into<String>) -> Self {
Self {
symbol_id,
derives: vec![derive.into()],
}
}
}
impl Mutation for AddDeriveMutation {
fn describe(&self) -> String {
format!(
"Add #[derive({})] to SymbolId({})",
self.derives.join(", "),
self.symbol_id
)
}
fn mutation_type(&self) -> &'static str {
"AddDerive"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}
#[derive(Debug, Clone)]
pub struct RemoveDeriveMutation {
pub symbol_id: SymbolId,
pub derives: Vec<String>,
}
impl RemoveDeriveMutation {
pub fn new(symbol_id: SymbolId, derives: Vec<String>) -> Self {
Self { symbol_id, derives }
}
pub fn single(symbol_id: SymbolId, derive: impl Into<String>) -> Self {
Self {
symbol_id,
derives: vec![derive.into()],
}
}
}
impl Mutation for RemoveDeriveMutation {
fn describe(&self) -> String {
format!(
"Remove #[derive({})] from SymbolId({})",
self.derives.join(", "),
self.symbol_id
)
}
fn mutation_type(&self) -> &'static str {
"RemoveDerive"
}
fn box_clone(&self) -> Box<dyn Mutation> {
Box::new(self.clone())
}
}