#[macro_export]
macro_rules! binding {
($value:expr) => {
$crate::data_binding::Binding::new($value)
};
}
#[macro_export]
macro_rules! computed {
($compute:expr, $initial:expr) => {
$crate::data_binding::Computed::new($compute, $initial)
};
}
#[cfg(test)]
mod tests {
#[test]
fn test_binding_macro() {
let b = binding!(42);
assert_eq!(b.get(), 42);
}
#[test]
fn test_binding_macro_with_string() {
let b = binding!("hello".to_string());
assert_eq!(b.get(), "hello");
}
#[test]
fn test_computed_macro() {
let mut c = computed!(|| 2 + 2, 0);
assert_eq!(c.get(), 4);
}
#[test]
fn test_computed_macro_with_closure() {
let x = 10;
let mut c = computed!(move || x * 3, 0);
assert_eq!(c.get(), 30);
}
}