code as a view.
For the rare part of a screen that is easier to build by hand than to describe: code implements Imperative, which makes the node on a build and brings it up to date on the next.
Signature
pub const fn imperative<T>(code: T) -> Custom<T>Example
use fusuma::{BuildError, Cx, Imperative, NodeId, Style, column, imperative, text};
/// A gap of a fixed height, built by hand.
struct Gap;
impl Imperative<()> for Gap {
fn build<const N: usize, const K: usize>(
&self,
cx: &mut Cx<'_, (), N, K>,
parent: Option<NodeId>,
) -> Result<NodeId, BuildError> {
cx.tree.spacer(parent, Style::new())
}
fn update<const N: usize, const K: usize>(&self, _: &mut Cx<'_, (), N, K>, _: NodeId) {}
}
let view = column((text("Above"), imperative(Gap), text("Below")));
let built = fusuma::doc::built::<(), _>(&view);
assert_eq!(built.texts(), ["Above", "Below"]);