Add some missing doc comments

Signed-off-by: Ben Aaron Goldberg <ben@benaaron.dev>
This commit is contained in:
Ben Aaron Goldberg 2021-10-23 20:43:12 -04:00
parent 63dd63c230
commit a0ce9ea8cb
2 changed files with 11 additions and 0 deletions

View file

@ -83,6 +83,7 @@ impl InstanceSettings {
Self::parse_prefstring(pref_string)?.select_pronoun(&self, name) Self::parse_prefstring(pref_string)?.select_pronoun(&self, name)
} }
/// Parse a pref_string.
pub fn parse_prefstring(pref_string: Option<&str>) -> Result<UserPreferences, ParseError> { pub fn parse_prefstring(pref_string: Option<&str>) -> Result<UserPreferences, ParseError> {
match pref_string { match pref_string {
Some(pref_string) => UserPreferences::from_prefstring(pref_string), Some(pref_string) => UserPreferences::from_prefstring(pref_string),

View file

@ -83,6 +83,16 @@ pub trait Preference {
BASE32_NOPAD.encode(&self.into_prefstring_bytes()) 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> { fn select_pronoun<'a>(&self, settings: &'a InstanceSettings, name: Option<&str>) -> Result<&'a Pronoun, ParseError> {
let seed = match name { let seed = match name {
Some(name) => name.as_bytes(), Some(name) => name.as_bytes(),