Struct cursive::event::Callback [] [src]

pub struct Callback(_);

Callback is a function that can be triggered by an event. It has a mutable access to the cursive root.

Methods

impl Callback
[src]

fn from_fn<F: Fn(&mut Cursive) + 'static>(f: F) -> Self

Wraps the given function into a Callback object.

Methods from Deref<Target=Box<Fn(&mut Cursive)>>

fn downcast<T>(self) -> Result<Box<T>, Box<Any + 'static>> where T: Any
1.0.0

Attempt to downcast the box to a concrete type.

Examples

use std::any::Any;

fn print_if_string(value: Box<Any>) {
    if let Ok(string) = value.downcast::<String>() {
        println!("String ({}): {}", string.len(), string);
    }
}

fn main() {
    let my_string = "Hello World".to_string();
    print_if_string(Box::new(my_string));
    print_if_string(Box::new(0i8));
}

fn downcast<T>(self) -> Result<Box<T>, Box<Any + 'static + Send>> where T: Any
1.0.0

Attempt to downcast the box to a concrete type.

Examples

use std::any::Any;

fn print_if_string(value: Box<Any + Send>) {
    if let Ok(string) = value.downcast::<String>() {
        println!("String ({}): {}", string.len(), string);
    }
}

fn main() {
    let my_string = "Hello World".to_string();
    print_if_string(Box::new(my_string));
    print_if_string(Box::new(0i8));
}

Trait Implementations

impl Clone for Callback
[src]

fn clone(&self) -> Callback

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Deref for Callback
[src]

type Target = Box<Fn(&mut Cursive)>

The resulting type after dereferencing

fn deref<'a>(&'a self) -> &'a Box<Fn(&mut Cursive)>

The method called to dereference a value

impl From<Rc<Box<Fn(&mut Cursive)>>> for Callback
[src]

fn from(f: Rc<Box<Fn(&mut Cursive)>>) -> Self

Performs the conversion.

impl From<Box<Fn(&mut Cursive) + Send>> for Callback
[src]

fn from(f: Box<Fn(&mut Cursive) + Send>) -> Self

Performs the conversion.

impl From<Box<Fn(&mut Cursive)>> for Callback
[src]

fn from(f: Box<Fn(&mut Cursive)>) -> Self

Performs the conversion.