Expand Pronoun struct

This commit is contained in:
Emi Simpson 2021-10-21 14:38:20 -04:00
parent 4ce602c14a
commit b04d8ed8bc
Signed by: Emi
GPG Key ID: A12F2C2FFDC3D847
1 changed files with 42 additions and 9 deletions

View File

@ -40,10 +40,26 @@ impl InstanceSettings {
todo!()
}
pub fn parse_prefstring(&self, pref_string: Option<impl AsRef<str>>) -> &str {
todo!()
}
}
impl Default for InstanceSettings {
fn default() -> Self {
let pronouns: Vec<Pronoun> = vec![
["she", "her", "her", "hers", "herself" ].into(),
["he", "him", "his", "his", "himself" ].into(),
["they", "them", "their", "theirs", "themself" ].into(),
["it", "it", "its", "its", "itself" ].into(),
["xe", "xem", "xyr", "xyrs", "xemself" ].into(),
["ze", "zem", "zyr", "zyrs", "zemself" ].into(),
["fae", "faer", "faer", "faers", "faerself" ].into(),
["ne", "nem", "nir", "nirs", "nirself" ].into(),
["e", "em", "eir", "eirs", "eirself" ].into(),
["vey", "vem", "ver", "vers", "verself" ].into(),
];
InstanceSettings {
pronoun_list: pronouns
}
}
}
/// A standard five-form pronoun set
@ -95,6 +111,18 @@ pub struct Pronoun {
}
impl Pronoun {
pub fn render_threeform(&self) -> String {
format!("{}/{}/{}", self.subject_pronoun, self.object_pronoun, self.possesive_pronoun)
}
}
impl fmt::Display for Pronoun {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.render_threeform())
}
}
impl From<[String; 5]> for Pronoun {
fn from(five_form: [String; 5]) -> Self {
let mut five_form = IntoIterator::into_iter(five_form);
@ -109,15 +137,20 @@ impl From<[String; 5]> for Pronoun {
}
}
impl From<[&str; 5]> for Pronoun {
fn from(five_form: [&str; 5]) -> Self {
(&five_form).into()
}
}
impl From<&[&str; 5]> for Pronoun {
fn from(five_form: &[&str; 5]) -> Self {
let mut five_form = IntoIterator::into_iter(five_form);
Pronoun {
subject_pronoun: five_form.next().unwrap().to_string(),
object_pronoun: five_form.next().unwrap().to_string(),
possesive_determiner: five_form.next().unwrap().to_string(),
possesive_pronoun: five_form.next().unwrap().to_string(),
reflexive_pronoun: five_form.next().unwrap().to_string(),
subject_pronoun: five_form[0].to_string(),
object_pronoun: five_form[1].to_string(),
possesive_determiner: five_form[2].to_string(),
possesive_pronoun: five_form[3].to_string(),
reflexive_pronoun: five_form[4].to_string(),
}
}
}