use alloc::string::String;
use core::fmt::{Display, Formatter, Result};
use crate::ToArg;
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Variable {
pub name: String,
pub value: String,
}
impl Variable {
pub fn new(name: impl ToArg, value: impl ToArg) -> Self {
Self {
name: name.to_arg(),
value: value.to_arg(),
}
}
}
impl Display for Variable {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{} = {}", self.name, self.value)
}
}
pub trait Variables: Sized {
fn add_variable_internal(&self, v: Variable);
fn variable(self, name: impl ToArg, value: impl ToArg) -> Self {
self.add_variable_internal(Variable::new(name, value));
self
}
}