Expand description
A name with two faces: the one a database sees and the one Rust can spell.
A column is declared once and used twice — as the string in a CREATE TABLE, a try_get, a
#[serde(rename = "…")] and an error message, and as the IDENT of the field that carries it in
an emitted row. Those two are not always the same string: type and bit-rate are ordinary
column names and neither is a legal field name.
Keeping them in ONE value is what stops them drifting. A pair of strings passed around
separately gets swapped eventually — and the failure is silent, because a mangled name still
compiles and a column called bit_rate still exists somewhere. Here the choice is made by the
trait a use site reaches for: quoting a name into an expansion yields the Rust face, and
formatting it yields the external one.
Borrowed from polarsync-codegen’s RustSafeName, which carries the same two faces for the
same reason.
Structs§
- Rust
Safe Name - A name as the database spells it, together with the identifier Rust can spell it as.