Skip to main content

Field

Trait Field 

Source
pub trait Field<F> {
    type Child;

    const SOURCE: &'static [&'static str];

    // Required methods
    fn get(&self) -> &Self::Child;
    fn get_mut(&mut self) -> &mut Self::Child;
}
Expand description

Access a composite field route and describe its child type and source spellings.

Each eligible field has a nominal marker generated by the composite macro. Use crate::field! to name a field or an arbitrarily nested route, such as field!(Composite::field::nested). The marker need not be named directly. The child is the exact authored field type in the parent declaration scope. Imported aliases and associated/generic child types retain Rust identity. Ordinary state fields do not participate in field routes or capability lifting. Without program-image-execution, legacy #[loadable] fields also stop route traversal and capability lifting; their sections are loaded separately.

Use this trait in bounds on consumers of field routes. Implementations are supplied by crate::composite and the generated route traversal.

Required Associated Constants§

Source

const SOURCE: &'static [&'static str]

Canonical name of the final field first, then its aliases in declaration order.

Required Associated Types§

Source

type Child

The exact type of the final child selected by the route.

Required Methods§

Source

fn get(&self) -> &Self::Child

Borrow the selected child for the lifetime of this composite borrow.

Source

fn get_mut(&mut self) -> &mut Self::Child

Mutably borrow the selected child for the lifetime of this composite borrow.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§