pub struct Many<T: Ranting>(pub Vec<T>);Expand description
Wraps a Vec<T> so it can be used as a say!() placeholder subject/argument.
Grammatically a Many<T> behaves as a single collective noun phrase: its rendered name is
the items’ own names joined as "a, b and c" (Oxford-comma-free), pluralized to they/them
grammar whenever the collection doesn’t hold exactly one item.
- Empty (
Many(vec![])): renders as the empty string, is treated as plural (“there are no items”, not “there is no item”), andskip_articlereturnstrue. - One item: subject pronoun, plurality, and custom-hook overrides all delegate straight
through to that item, so
Many(vec![noun])behaves likenounalone. - Several items: subject pronoun is
"they"/plural agreement; custom hooks (which are per-item, not per-collection) fall back to the built-in English rules, since there’s no single item to delegate to.
Placeholder verbs are always written in their base plural form (e.g. are, not is) — see
the crate-level docs on say!() — so a Many with exactly one item still reads {=solo are}
in the template even though it renders singular (“is”).
§Examples
let heroes = Many(vec![Noun::new("Alice", "she"), Noun::new("Bob", "he")]);
assert_eq!(say!("{=heroes are} ready."), "They are ready.".to_string());
assert_eq!(say!("{heroes}"), "Alice and Bob".to_string());
let solo = Many(vec![Noun::new("Alice", "she")]);
assert_eq!(say!("{=solo are} ready."), "She is ready.".to_string());
let none: Many<Noun> = Many(vec![]);
assert_eq!(say!("{=none are} out of stock."), "They are out of stock.".to_string());Tuple Fields§
§0: Vec<T>Trait Implementations§
impl<T: Eq + Ranting> Eq for Many<T>
Source§impl<T: Ranting> Ranting for Many<T>
impl<T: Ranting> Ranting for Many<T>
Source§fn name(&self, uc: bool) -> String
fn name(&self, uc: bool) -> String
The entity’s display name, with its first character uppercased when
uc is set. Read moreSource§fn subjective(&self) -> &str
fn subjective(&self) -> &str
The entity’s subject pronoun: “I”, “you”, “thou”, “he”, “she”, “it”, “we”, “ye” or
“they”. Every other pronoun a placeholder renders is inflected from this one. Read more
Source§fn is_plural(&self) -> bool
fn is_plural(&self) -> bool
Whether the entity is plural, which decides the agreement form of every verb and
pronoun rendered beside it. Read more
Source§fn inflect(
&self,
to_plural: bool,
uc: bool,
case: GrammaticalCase,
count: Option<PlaceholderCount>,
) -> String
fn inflect( &self, to_plural: bool, uc: bool, case: GrammaticalCase, count: Option<PlaceholderCount>, ) -> String
The name in the number the placeholder asked for, uppercased when
uc is set. Read moreSource§fn skip_article(&self) -> bool
fn skip_article(&self) -> bool
Whether a placeholder should render no article for this entity — true for names,
languages, meals and sports, which take one only for emphasis. Read more
Source§fn noun_class(&self) -> NounClass
fn noun_class(&self) -> NounClass
The noun’s lexical gender / noun class, or
NounClass::UNSET (the default) when it
declares none. Set it with #[ranting(gender = "...")], or on a Noun with
Noun::with_noun_class. Read moreSource§fn is_first_person_subject_custom(&self, subject: &str) -> bool
fn is_first_person_subject_custom(&self, subject: &str) -> bool
Whether
subject counts as first-person (the narrator) for
NarrationContext::narration_person viewpoint overrides —
consulted by say_with!()’s viewpoint resolution before anything else, so overriding
this is enough to make a non-English first-person label (ich, wir, …) participate
in viewpoint retelling. The default is English’s own rule, subject == "I" || subject == "we". Read moreSource§fn capitalize(
&self,
word: &str,
role: OrthographyRole,
uc: bool,
sentence_start: bool,
) -> String
fn capitalize( &self, word: &str, role: OrthographyRole, uc: bool, sentence_start: bool, ) -> String
Apply orthographic capitalization to one rendered piece of a placeholder. Read more
Source§fn capitalize_with_context(
&self,
word: &str,
role: OrthographyRole,
uc: bool,
sentence_start: bool,
ctx: Option<&NarrationContext>,
) -> String
fn capitalize_with_context( &self, word: &str, role: OrthographyRole, uc: bool, sentence_start: bool, ctx: Option<&NarrationContext>, ) -> String
Like
capitalize, but also receives the
NarrationContext in effect for this call, when there is one — which is where a
locale (NarrationContext::dialect, e.g. "tr") would live for a fork that needs
Turkish dotted/dotless i. See
inflect_verb_custom_with_context for the
general shape: every call site calls this one, and the default delegates to capitalize
with ctx ignored.Source§fn inflect_verb_custom(
&self,
subject: &str,
verb: &str,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
) -> Option<String>
fn inflect_verb_custom( &self, subject: &str, verb: &str, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ) -> Option<String>
Customize verb conjugation (tense, plurality, person).
Return Some(String) to use custom form, None to fall back to English. Read more
Source§fn inflect_verb_custom_with_context(
&self,
subject: &str,
verb: &str,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn inflect_verb_custom_with_context( &self, subject: &str, verb: &str, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
inflect_verb_custom, but also receives the
NarrationContext in effect for this call, when there is one. Read moreSource§fn inflect_pronoun_custom(
&self,
subject: &str,
case: PronounCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
) -> Option<String>
fn inflect_pronoun_custom( &self, subject: &str, case: PronounCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ) -> Option<String>
Customize pronoun inflection (subject/object/possessive forms).
Return Some(String) to use custom form, None to fall back to English. Read more
Source§fn inflect_pronoun_custom_with_context(
&self,
subject: &str,
case: PronounCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn inflect_pronoun_custom_with_context( &self, subject: &str, case: PronounCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
inflect_pronoun_custom, but also receives the
NarrationContext in effect for this call, when there is one. See
inflect_verb_custom_with_context for the
general shape: every pronoun call site calls this one, and the default delegates to
inflect_pronoun_custom with ctx ignored.Source§fn inflect_article_custom(
&self,
article: &str,
noun_singular: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
) -> Option<String>
fn inflect_article_custom( &self, article: &str, noun_singular: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ) -> Option<String>
Customize article inflection (a/an/the/some, demonstratives, etc.).
Return Some(String) to use custom form, None to fall back to English. Read more
Source§fn inflect_article_custom_with_context(
&self,
article: &str,
noun_singular: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn inflect_article_custom_with_context( &self, article: &str, noun_singular: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
inflect_article_custom, but also receives the
NarrationContext in effect for this call, when there is one. See
inflect_verb_custom_with_context for the
general shape: every article call site calls this one, and the default delegates to
inflect_article_custom with ctx ignored.Source§fn elide_article_custom(
&self,
article: &str,
separator: &str,
following: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
) -> Option<String>
fn elide_article_custom( &self, article: &str, separator: &str, following: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, ) -> Option<String>
Elide or fuse a rendered article with the word that follows it. Read more
Source§fn elide_article_custom_with_context(
&self,
article: &str,
separator: &str,
following: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn elide_article_custom_with_context( &self, article: &str, separator: &str, following: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
elide_article_custom, but also receives the
NarrationContext in effect for this call, when there is one. See
inflect_verb_custom_with_context for the
general shape: the elision call site calls this one, and the default delegates to
elide_article_custom with ctx ignored.Source§fn elide_numeral_custom(
&self,
numeral: &str,
separator: &str,
following: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
) -> Option<String>
fn elide_numeral_custom( &self, numeral: &str, separator: &str, following: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, ) -> Option<String>
Fuse a rendered numeral with the noun that follows it — the numeral-side twin of
elide_article_custom. Read moreSource§fn elide_numeral_custom_with_context(
&self,
numeral: &str,
separator: &str,
following: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn elide_numeral_custom_with_context( &self, numeral: &str, separator: &str, following: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
elide_numeral_custom, but also receives the
NarrationContext when the call came from say_with!(). Defaults to delegating, so
overriding either one alone is enough.Source§fn inflect_preposition_custom(
&self,
preposition: &str,
article: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
) -> Option<String>
fn inflect_preposition_custom( &self, preposition: &str, article: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ) -> Option<String>
Fuse a literal preposition, written in the template immediately before a placeholder, with
the article that placeholder renders. Read more
Source§fn inflect_preposition_custom_with_context(
&self,
preposition: &str,
article: &str,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn inflect_preposition_custom_with_context( &self, preposition: &str, article: &str, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
inflect_preposition_custom, but also receives
the NarrationContext in effect for this call, when there is one. See
inflect_verb_custom_with_context for the
general shape: the preposition-fusion call site calls this one, and the default delegates
to inflect_preposition_custom with ctx ignored.Source§fn inflect_adjective_custom(
&self,
adjective: &str,
degree: AdjectiveDegree,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
) -> Option<String>
fn inflect_adjective_custom( &self, adjective: &str, degree: AdjectiveDegree, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ) -> Option<String>
Customize a post-noun adjective (the
!/!! degree slot).
Return Some(String) to use a custom form, None to keep the compile-time-resolved English
comparative/superlative. Read moreSource§fn inflect_adjective_custom_with_context(
&self,
adjective: &str,
degree: AdjectiveDegree,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
count: Option<PlaceholderCount>,
uc: bool,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn inflect_adjective_custom_with_context( &self, adjective: &str, degree: AdjectiveDegree, case: GrammaticalCase, class: NounClass, as_plural: bool, count: Option<PlaceholderCount>, uc: bool, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
inflect_adjective_custom, but also receives the
NarrationContext in effect for this call, when there is one. See
inflect_verb_custom_with_context for the
general shape: the adjective call site calls this one, and the default delegates to
inflect_adjective_custom with ctx ignored.Source§fn inflect_numeral_custom(
&self,
numeral: &str,
count: Option<i64>,
style: NumeralStyle,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
) -> Option<String>
fn inflect_numeral_custom( &self, numeral: &str, count: Option<i64>, style: NumeralStyle, case: GrammaticalCase, class: NounClass, as_plural: bool, ) -> Option<String>
Customize how a placeholder’s number is written (the
#var/$var slot).
Return Some(String) to use a custom numeral, None to keep the English rendering. Read moreSource§fn inflect_numeral_custom_with_context(
&self,
numeral: &str,
count: Option<i64>,
style: NumeralStyle,
case: GrammaticalCase,
class: NounClass,
as_plural: bool,
ctx: Option<&NarrationContext>,
) -> Option<String>
fn inflect_numeral_custom_with_context( &self, numeral: &str, count: Option<i64>, style: NumeralStyle, case: GrammaticalCase, class: NounClass, as_plural: bool, ctx: Option<&NarrationContext>, ) -> Option<String>
Like
inflect_numeral_custom, but also receives the
NarrationContext in effect for this call, when there is one — which is
where a locale (NarrationContext::dialect) selecting a digit system would live. See
inflect_verb_custom_with_context for the
general shape: the numeral call site calls this one, and the default delegates to
inflect_numeral_custom with ctx ignored.impl<T: PartialEq + Ranting> StructuralPartialEq for Many<T>
Auto Trait Implementations§
impl<T> Freeze for Many<T>
impl<T> RefUnwindSafe for Many<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for Many<T>
impl<T> Sync for Many<T>
impl<T> Unpin for Many<T>
impl<T> UnsafeUnpin for Many<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for Many<T>where
Vec<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more