MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / format_count_auto

Function format_count_auto

atomic-cli/src/commands/mod.rs:716–722  ·  view source on GitHub ↗

Format a count with auto-pluralization (appends 's'). Convenience wrapper around [`format_count`] for regular English nouns where the plural is just the singular + 's'. # Arguments `count` - The count `singular` - The singular form of the noun (plural = singular + "s") # Example ```rust,ignore assert_eq!(format_count_auto(1, "change"), "1 change"); assert_eq!(format_count_auto(5, "change"), "

(count: usize, singular: &str)

Source from the content-addressed store, hash-verified

714/// assert_eq!(format_count_auto(5, "change"), "5 changes");
715/// ```
716pub fn format_count_auto(count: usize, singular: &str) -> String {
717 if count == 1 {
718 format!("1 {}", singular)
719 } else {
720 format!("{} {}s", count, singular)
721 }
722}
723
724// Tests
725

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected