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

Function format_count

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

Format a count with singular/plural label. # Arguments `count` - The count `singular` - The singular form of the noun `plural` - The plural form of the noun # Returns A formatted string like "1 file" or "3 files". # Example ```rust,ignore assert_eq!(format_count(1, "file", "files"), "1 file"); assert_eq!(format_count(3, "file", "files"), "3 files"); ```

(count: u64, singular: &str, plural: &str)

Source from the content-addressed store, hash-verified

690/// assert_eq!(format_count(3, "file", "files"), "3 files");
691/// ```
692pub fn format_count(count: u64, singular: &str, plural: &str) -> String {
693 if count == 1 {
694 format!("1 {}", singular)
695 } else {
696 format!("{} {}", count, plural)
697 }
698}
699
700/// Format a count with auto-pluralization (appends 's').
701///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected