hooked/hooked-cli/source/utilities.rs

15 lines
311 B
Rust
Raw Normal View History

2022-10-31 21:05:47 +00:00
//! Miscellaneous utilities.
/// Simple function to create a pluralized string.
pub fn plural(count: usize, singular: &str, plural: Option<&str>) -> String {
2022-11-01 11:27:01 +00:00
if count == 1 {
2022-10-31 21:05:47 +00:00
return singular.to_string();
}
if let Some(plural) = plural {
return plural.to_string();
}
format!("{singular}s")
}