Skip to main content

Piece

Trait Piece 

Source
pub trait Piece: 'static {
    // Required method
    fn build(self, cx: &mut BuildCx) -> RNode;
}
Expand description

A UI description consumed once (§5.2). Returns the root realized node it created.

Required Methods§

Source

fn build(self, cx: &mut BuildCx) -> RNode

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<P: Piece> Piece for Option<P>

An optional piece (§5.1): Some builds the piece, None builds the same zero-size, layout-transparent anchor a false when leaves behind, so the slot keeps its place in a tuple without drawing anything.

ⓘ
let precip = (d.precip > 0).then(|| label(format!("{}%", d.precip)));
row((icon, precip))

Resolved once at build. For an Option that changes while the piece lives, use keyed(move || state.get(), |v| …).

Source§

fn build(self, cx: &mut BuildCx) -> RNode

Implementors§

Source§

impl Piece for AnyPiece

Source§

impl Piece for ComposedSheet

Source§

impl<A: Piece, B: Piece> Piece for Either<A, B>

Source§

impl<F: FnOnce(&mut BuildCx) -> RNode + 'static> Piece for PieceFn<F>

Day API ↩ Guides· daybrite.dev