diff --git a/src/lib.rs b/src/lib.rs index 251f4d2..a5435f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,6 +83,7 @@ impl InstanceSettings { Self::parse_prefstring(pref_string)?.select_pronoun(&self, name) } + /// Parse a pref_string. pub fn parse_prefstring(pref_string: Option<&str>) -> Result { match pref_string { Some(pref_string) => UserPreferences::from_prefstring(pref_string), diff --git a/src/user_preferences/mod.rs b/src/user_preferences/mod.rs index 7ccb6ec..dedd069 100644 --- a/src/user_preferences/mod.rs +++ b/src/user_preferences/mod.rs @@ -83,6 +83,16 @@ pub trait Preference { BASE32_NOPAD.encode(&self.into_prefstring_bytes()) } + /// Select a pronoun for today using this Preference's WeightedTable. + /// + /// Is shorthand for + /// + /// ``` + /// # use pronouns_today::InstanceSettings; + /// # let settings = InstanceSettings::default(); + /// # let seed = &[]; + /// self.into_weighted_table(settings)?.select_today(seed) + /// ``` fn select_pronoun<'a>(&self, settings: &'a InstanceSettings, name: Option<&str>) -> Result<&'a Pronoun, ParseError> { let seed = match name { Some(name) => name.as_bytes(),