Skip to main content

Many

Struct Many 

Source
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”), and skip_article returns true.
  • One item: subject pronoun, plurality, and custom-hook overrides all delegate straight through to that item, so Many(vec![noun]) behaves like noun alone.
  • 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§

Source§

impl<T: Clone + Ranting> Clone for Many<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Ranting> Debug for Many<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Ranting> Default for Many<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Ranting> Display for Many<T>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq + Ranting> Eq for Many<T>

Source§

impl<T: PartialEq + Ranting> PartialEq for Many<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T: Ranting> Ranting for Many<T>

Source§

fn name(&self, uc: bool) -> String

The entity’s display name, with its first character uppercased when uc is set. Read more
Source§

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

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

The name in the number the placeholder asked for, uppercased when uc is set. Read more
Source§

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

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 more
Source§

fn is_mass(&self) -> bool

Whether the entity is a mass noun (“information”, “water”) rather than a count noun (“item”, “boot”) – orthogonal to NounClass: a word can be both, since many languages have a lexical gender for their mass nouns too (German das Wasser is neuter and mass). Read more
Source§

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 more
Source§

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

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>

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>

Like inflect_verb_custom, but also receives the NarrationContext in effect for this call, when there is one. Read more
Source§

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>

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>

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>

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>

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>

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>

Fuse a rendered numeral with the noun that follows it — the numeral-side twin of elide_article_custom. Read more
Source§

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>

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>

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>

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 more
Source§

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>

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 more
Source§

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.
Source§

impl<T: PartialEq + Ranting> StructuralPartialEq for Many<T>

Auto Trait Implementations§

§

impl<T> Freeze for Many<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for Many<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for Many<T>
where Vec<T>: Send,

§

impl<T> Sync for Many<T>
where Vec<T>: Sync,

§

impl<T> Unpin for Many<T>
where Vec<T>: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.