[−][src]Struct verba::noun::irregular::Irregular
Methods
impl Irregular
[src]
pub fn new(
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String,
group: Group
) -> Result<Irregular, IrregularError>
[src]
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String,
group: Group
) -> Result<Irregular, IrregularError>
Creates an irregular Latin noun.
Latin nouns can contain declensions that do not follow the rules of any regular declension group. These nouns are, not surprisingly, referred to as irregular.
This function provides a method for creating irregular nouns. Unlike
[Regular::new
], which takes the singular nominative and genitive
forms, this function takes a HashMap containing all of the irregular
declined forms, the stem, and the declension group. If a declined form
isn't present in the HashMap, it is assumed to be regular and will be
declined according to the regular Latin rules for the passed in
declension group.
For example, if the HashMap contains values for the singular dative
form but not the singular ablative form, the singular dative form will
be declined as it appears in the HashMap but the singular ablative form
will be declined the same as a noun created using [Regular::new
].
Warning
Third declension nouns have a singular nominative and vocative (and
accusative in the case of neuter nouns) form that cannot be declined
by combining the stem with an ending. Because of this, calling
[Irregular::decline
] on a third declension noun for those cases will
return [Non
] unless they are added to the declension HashMap.
Warning
Third declension nouns can be either consonant-stem or i-stem. Third
declension nouns created with this function will decline as consonant-
stem. When creating a third declension i-stem noun, use
[new_third_i_stem
] instead.
Example
vīs, vīs is an irregular noun with an irregular singular genitive form. The stem is vīr- but none of the singular cases use. Moreover, the plural cases decline like a third declension i-stem. So all six singular forms must be provided as do the plural genitive and accusative forms. The rest of the forms can be determined by combining the provided stem with the regular third declension endings.
This example shows how to create the HashMap containing the irregular declined forms and demonstrates two declensions. The first declension is regular, the second is irregular.
use std::collections::HashMap; use verba::noun as N; use verba::noun::{Noun}; let mut declension = HashMap::new(); declension.insert((N::Number::Singular, N::Case::Nominative), Some(vec!["vīs".to_string()])); declension.insert((N::Number::Singular, N::Case::Genitive), Some(vec!["vīs".to_string()])); declension.insert((N::Number::Singular, N::Case::Dative), Some(vec!["vī".to_string()])); declension.insert((N::Number::Singular, N::Case::Accusative), Some(vec!["vim".to_string()])); declension.insert((N::Number::Singular, N::Case::Ablative), Some(vec!["vī".to_string()])); declension.insert((N::Number::Singular, N::Case::Vocative), Some(vec!["vīs".to_string()])); declension.insert((N::Number::Plural, N::Case::Genitive), Some(vec!["vīrium".to_string()])); declension.insert((N::Number::Plural, N::Case::Accusative), Some(vec!["vīrēs".to_string(), "vīrīs".to_string()])); let noun = N::Irregular::new(declension, N::Gender::Feminine, "vīr".to_string(), N::Group::Third).unwrap(); assert_eq!(noun.decline(N::Number::Plural, N::Case::Nominative), Some(vec!["vīrēs".to_string()])); assert_eq!(noun.decline(N::Number::Plural, N::Case::Genitive), Some(vec!["vīrium".to_string()]));
pub fn new_second_ius(
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String
) -> Result<Irregular, IrregularError>
[src]
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String
) -> Result<Irregular, IrregularError>
pub fn new_third_i_stem(
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String
) -> Result<Irregular, IrregularError>
[src]
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String
) -> Result<Irregular, IrregularError>
pub fn new_fourth_u(
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String
) -> Result<Irregular, IrregularError>
[src]
declensions: HashMap<(Number, Case), Option<Vec<String>>>,
gender: Gender,
stem: String
) -> Result<Irregular, IrregularError>
Trait Implementations
impl Noun for Irregular
[src]
fn gender(&self) -> Gender
[src]
fn stem(&self) -> Option<&str>
[src]
fn group(&self) -> Option<Group>
[src]
fn decline(&self, number: Number, case: Case) -> Option<Vec<String>>
[src]
impl Clone for Irregular
[src]
fn clone(&self) -> Irregular
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Irregular
[src]
Auto Trait Implementations
impl Sync for Irregular
impl Unpin for Irregular
impl Send for Irregular
impl UnwindSafe for Irregular
impl RefUnwindSafe for Irregular
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,