pub enum Handler<M> {
Plain(M),
Bool(fn(bool) -> M),
Index(fn(usize) -> M),
Number(fn(f32) -> M),
}Expand description
A message a form named, in the shape the widget holding it needs.
Widgets do not all take a message the same way, and none of them takes a
closure: a Button holds an M, a Checkbox a fn(bool) -> M, a List a
fn(usize) -> M, a Slider a fn(f32) -> M. Those are function
pointers, so nothing this crate could build from a name would fit — but an
enum’s tuple variant already is one:
#[derive(Clone, Copy)]
enum Message {
Save,
Notify(bool),
}
let save = Handler::Plain(Message::Save);
// `Message::Notify` *is* a `fn(bool) -> Message`.
let notify = Handler::Bool(Message::Notify);Variants§
Plain(M)
The message itself, for a widget that holds one: a button, a select, a text field’s submit.
Bool(fn(bool) -> M)
fn(bool) -> M — a checkbox, a toggle, a collapse.
Index(fn(usize) -> M)
fn(usize) -> M — anything that selects one of several.
Number(fn(f32) -> M)
fn(f32) -> M — a slider, a rating.
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Handler<M>
impl<M> RefUnwindSafe for Handler<M>where
M: RefUnwindSafe,
fn(bool) -> M: RefUnwindSafe,
fn(usize) -> M: RefUnwindSafe,
fn(f32) -> M: RefUnwindSafe,
impl<M> Send for Handler<M>
impl<M> Sync for Handler<M>
impl<M> Unpin for Handler<M>
impl<M> UnsafeUnpin for Handler<M>where
M: UnsafeUnpin,
fn(bool) -> M: UnsafeUnpin,
fn(usize) -> M: UnsafeUnpin,
fn(f32) -> M: UnsafeUnpin,
impl<M> UnwindSafe for Handler<M>where
M: UnwindSafe,
fn(bool) -> M: UnwindSafe,
fn(usize) -> M: UnwindSafe,
fn(f32) -> M: UnwindSafe,
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