Skip to main content

View

Trait View 

Source
pub trait View {
    // Required method
    fn show(self, cx: &mut Cx<'_, '_>);
}
Expand description

Something that can draw itself into a Cx.

The canonical implementation is a closure, which is what rsx! expands to. The other impls exist so that plain values ("text", Option, Vec) can be dropped into a child slot without ceremony.

Required Methods§

Source

fn show(self, cx: &mut Cx<'_, '_>)

Draw this view.

Implementations on Foreign Types§

Source§

impl View for &str

Source§

fn show(self, cx: &mut Cx<'_, '_>)

Source§

impl View for ()

Draws nothing. This is what an empty child slot is.

Source§

fn show(self, _cx: &mut Cx<'_, '_>)

Source§

impl View for String

Source§

fn show(self, cx: &mut Cx<'_, '_>)

Source§

impl<V: View> View for Option<V>

Source§

fn show(self, cx: &mut Cx<'_, '_>)

Source§

impl<V: View> View for Vec<V>

Source§

fn show(self, cx: &mut Cx<'_, '_>)

Source§

impl<V: View, const N: usize> View for [V; N]

Source§

fn show(self, cx: &mut Cx<'_, '_>)

Implementors§

Source§

impl<F: FnOnce(&mut Cx<'_, '_>)> View for F

The escape hatch: any closure taking a Cx is a view.

A blanket impl over IntoIterator would be nicer than the Vec and array impls above, but it overlaps both this one and Option, so the concrete impls stay.