Skip to main content

arti_path_from_components

Function arti_path_from_components 

Source
pub fn arti_path_from_components(
    path_comps: &[&dyn RawKeySpecifierComponent],
    leaf_comps: &[&dyn RawKeySpecifierComponent],
) -> Result<ArtiPath, ArtiPathUnavailableError>
Expand description

Make an ArtiPath like pc/pc/pc/lc_lc_lc

This is the engine for the KeySpecifier macro’s arti_path() impls.

The macro-generated code sets up couple of vectors. Each vector entry is a pointer to the field in the original struct, plus a vtable pointer saying what to do with it.

For fixed elements in the path, the vtable entry’s data pointer is a pointer to a constant &str.

In the macro, this is done by the user-defined expansion ARTI_FROM_COMPONENTS_ARGS.

Doing it this way minimises the amount of macro-generated machine code.