pub struct BindingExpression<S: Clone + 'static, T: Clone + 'static> { /* private fields */ }Expand description
A binding that transforms the source value before pushing to the sink.
Uses a Computed internally so the transform result is cached
and only re-evaluated when the source changes.
§Examples
ⓘ
let count = Signal::new(3);
let label = Rc::new(RefCell::new(String::new()));
let binding = BindingExpression::new(
&count,
|v: &i32| format!("Count: {v}"),
{
let label = label.clone();
move |v: &String| *label.borrow_mut() = v.clone()
},
);
count.set(7);
assert_eq!(*label.borrow(), "Count: 7");Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<S, T> Freeze for BindingExpression<S, T>
impl<S, T> !RefUnwindSafe for BindingExpression<S, T>
impl<S, T> !Send for BindingExpression<S, T>
impl<S, T> !Sync for BindingExpression<S, T>
impl<S, T> Unpin for BindingExpression<S, T>
impl<S, T> !UnwindSafe for BindingExpression<S, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more