Skip to main content

Handler

Enum Handler 

Source
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§

Source§

impl<M: Clone> Clone for Handler<M>

Source§

fn clone(&self) -> Handler<M>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M: Copy> Copy for Handler<M>

Source§

impl<M: Debug> Debug for Handler<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<M> Freeze for Handler<M>
where M: Freeze, fn(bool) -> M: Freeze, fn(usize) -> M: Freeze, fn(f32) -> M: Freeze,

§

impl<M> RefUnwindSafe for Handler<M>

§

impl<M> Send for Handler<M>
where M: Send, fn(bool) -> M: Send, fn(usize) -> M: Send, fn(f32) -> M: Send,

§

impl<M> Sync for Handler<M>
where M: Sync, fn(bool) -> M: Sync, fn(usize) -> M: Sync, fn(f32) -> M: Sync,

§

impl<M> Unpin for Handler<M>
where M: Unpin, fn(bool) -> M: Unpin, fn(usize) -> M: Unpin, fn(f32) -> M: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Borrows as dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Mutably borrows as dyn Any.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.