Skip to main content

View

Trait View 

Source
pub trait View {
    // Required methods
    fn shape(&self) -> &dyn Shape;
    fn get(&self, key: Key) -> Value<'_>;

    // Provided method
    fn call(
        &self,
        key: Key,
        args: &[Value<'_>],
        with: &mut dyn FnMut(Value<'_>),
    ) { ... }
}
Expand description

What a template reads.

Required Methods§

Source

fn shape(&self) -> &dyn Shape

The names this view answers.

Source

fn get(&self, key: Key) -> Value<'_>

A field by key. The hot path: no allocation.

Provided Methods§

Source

fn call(&self, key: Key, args: &[Value<'_>], with: &mut dyn FnMut(Value<'_>))

A method with arguments (variations.options("size")). The result is passed to with, so it may borrow a value computed for the call. The default answers Value::Absent.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl View for Fields<'_>