pub fn inflect_noun_regular(
noun_form: &str,
to_plural: bool,
singular_end: Option<&str>,
plural_end: Option<&str>,
) -> StringExpand description
Inflect a noun the irregular table doesn’t list, by rule.
Called by derive-generated Ranting::inflect() impls after
inflect_noun_irregular returns None. singular_end/plural_end are the
#[ranting(..)] attributes as the struct declared them — literals, or the struct’s own
fields when the attribute is "$", which is why they arrive as runtime values rather than
being resolved in the macro.
Which path runs is decided by whether those attributes were written, and that is the
compatibility contract. Both absent (None): the noun goes through English’s regular
orthographic rules, so {+fly} renders
"flies" where it used to render "flys". Either one written: the struct has stated a rule
of its own, and that statement wins — it gets the literal strip-and-append, with the
unwritten half defaulting to ""/"s". That is what keeps a non-English impl relying on
plural_end from silently acquiring English spelling rules.
The parameters are Option rather than plain &str for one reason: #[ranting(plural_end = "s")] must be able to mean literal append-s, no English orthography. That is the opt-out
a language whose loanword plurals are bare -s needs — German Partys/Babys, Dutch,
Danish — and it was unreachable while the mode was inferred from the value, since "s" is
also the historical default. Names ending in a consonant + y are the class that actually
diverges: they were right by accident before the rules landed.
Singularization is the pre-existing strip-plural_end behavior in every case, deliberately —
the module docs on plurals give the counterexample classes that rule it out.
A form that doesn’t end in the suffix it would have to strip is returned unchanged rather than panicking: this runs at formatting time, on data.