pub trait IntoMsg<Msg>: Sized {
// Required method
fn defer(work: impl Fn() -> Self + 'static) -> Msg;
}Expand description
What a handler’s result can be turned into, so a widget’s setter takes both shapes: a closure that returns the widget’s message type, and — in an application built from components — one that just does the work and returns nothing.
let checked = Rc::new(Cell::new(false));
let flag = checked.clone();
// the closure does the work; there is no message to return
let _box: Checkbox = Checkbox::new(false).on_toggle(move |on| flag.set(on));A closure that returns () becomes a message that runs it: the work waits for the message
to be delivered, not for it to be made, because a widget may ask for its message more
than once for one interaction. Anything else is its own message, made at once.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".