Enum yew::callback::Callback[][src]

pub enum Callback<IN> {
    Callback(Rc<dyn Fn(IN)>),
    CallbackOnce(Rc<RefCell<Option<Box<dyn FnOnce(IN)>>>>),
}
Expand description

Universal callback wrapper.

An `Rc` wrapper is used to make it cloneable.

Variants

Callback(Rc<dyn Fn(IN)>)
Expand description

A callback which can be called multiple times

CallbackOnce(Rc<RefCell<Option<Box<dyn FnOnce(IN)>>>>)
Expand description

A callback which can only be called once. The callback will panic if it is called more than once.

Implementations

impl<IN> Callback<IN>[src]

pub fn emit(&self, value: IN)[src]

This method calls the callback’s function.

pub fn once<F>(func: F) -> Self where
    F: FnOnce(IN) + 'static, 
[src]

Creates a callback from an FnOnce. The programmer is responsible for ensuring that the callback is only called once. If it is called more than once, the callback will panic.

pub fn noop() -> Self[src]

Creates a “no-op” callback which can be used when it is not suitable to use an Option<Callback>.

impl<IN: 'static> Callback<IN>[src]

pub fn reform<F, T>(&self, func: F) -> Callback<T> where
    F: Fn(T) -> IN + 'static, 
[src]

Changes the input type of the callback to another. Works like the map method but in the opposite direction.

Trait Implementations

impl<IN> Clone for Callback<IN>[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<IN> Debug for Callback<IN>[src]

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

Formats the value using the given formatter. Read more

impl<IN> Default for Callback<IN>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl<IN, F: Fn(IN) + 'static> From<F> for Callback<IN>[src]

fn from(func: F) -> Self[src]

Performs the conversion.

impl<IN> PartialEq<Callback<IN>> for Callback<IN>[src]

fn eq(&self, other: &Callback<IN>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<T> ImplicitClone for Callback<T>[src]

Auto Trait Implementations

impl<IN> !RefUnwindSafe for Callback<IN>

impl<IN> !Send for Callback<IN>

impl<IN> !Sync for Callback<IN>

impl<IN> Unpin for Callback<IN>

impl<IN> !UnwindSafe for Callback<IN>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> Any for T where
    T: Any
[src]

impl<T> CloneAny for T where
    T: Any + Clone
[src]