pub struct Derived {
pub name: Ident,
pub source: Path,
pub field: Option<LitStr>,
}Expand description
One REVERSE position: a record that points at this one, under the name this record calls it by.
There is no Rust field for one, ever — no storage, no field, no lie. The declaration names a SOURCE and the framework already knows how the two meet, because the source’s own declaration said so; what this adds is the name the position is reached under and, where the source points back through several fields, which of them this position means.
Fields§
§name: IdentThe position’s name — the word the declaration wrote, which is also the name a wire face will expose it under.
Held to the same namespace as the record’s fields: an entry colliding with a real field is refused by the front end, because one face has one namespace.
source: PathThe record whose ref points back, exactly as the declaration spelled it.
A PATH rather than a resolved type, because a macro has tokens: every consequence of it is type-level — the audit names it in a bound — so an alias in the path is transparent and nothing here has to know what it resolves to.
field: Option<LitStr>field = "…" — WHICH of the source’s referring fields this position means, or None for the
shorthand.
A string, because a field name is not a type on stable Rust: the audit it produces is a
constant evaluation over the source’s emitted COLUMNS rather than a bound. The literal is
kept whole so a refusal about the name lands on the name.