pub struct CellFactory(pub Rc<RefCell<HashMap<&'static str, Box<dyn Fn() -> Box<dyn Any>>>>>);
Expand description

A CellFactory is an struct that stores closures that instantiate view types.

This is a pattern used in certain view types (e.g, ListView). This factory exists to enable dynamic view registration and dequeueing. It stores a closure and erases the type to Any, and supports querying for that time to get it back.

It is explicitly designed to panic if it’s unable to retrieve a stored item with the specified type, as the views that use this would cease to function if the type can’t be retrieved, and it’s better to blow up early.

Tuple Fields

0: Rc<RefCell<HashMap<&'static str, Box<dyn Fn() -> Box<dyn Any>>>>>

Implementations

Creates and returns a new CellFactory.

Store a closure for the given identifier.

Attempts to retrieve the closure, downcasted to the specified type. This will panic if it’s unable to retrieve the closure with the requested type.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.