Skip to main content

FieldOrder

Trait FieldOrder 

Source
pub trait FieldOrder {
    // Required method
    fn canonical(&mut self, names: &[&str]) -> Vec<String>;
}
Expand description

Who decides the layout order of the anonymous record a named-capture parser builds (§5.6, ADR-152).

An anonymous record’s identity is its field-name set, so two parsers that name the same fields in different orders produce one type — and a type has exactly one field order, because a field read compiles to a slot index. The order therefore cannot be a property of the parser that happens to be building the value; it has to come from whatever knows about every spelling in the program. During a compile that is the TypeDb, which registered a definition for each.

The plan stores the answer per record-producing node so the runtime places fields with an index rather than a name lookup.

Required Methods§

Source

fn canonical(&mut self, names: &[&str]) -> Vec<String>

The canonical order of the shape whose fields are names. The answer is a permutation of names — same set, possibly reordered.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl FieldOrder for TypeDb

Source§

fn canonical(&mut self, names: &[&str]) -> Vec<String>

Implementors§