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

Function format_count

atomic-cli/src/commands/clone/helpers.rs:619–625  ·  view source on GitHub ↗

Format a count with proper pluralization. # Arguments `count` - The number of items `singular` - The singular form of the word (e.g., "change") # Returns A string like "1 change" or "5 changes". # Example ```rust use atomic::commands::clone::helpers::format_count; assert_eq!(format_count(0, "change"), "0 changes"); assert_eq!(format_count(1, "change"), "1 change"); assert_eq!(format_count(5

(count: usize, singular: &str)

Source from the content-addressed store, hash-verified

617/// assert_eq!(format_count(5, "change"), "5 changes");
618/// ```
619pub fn format_count(count: usize, singular: &str) -> String {
620 if count == 1 {
621 format!("{} {}", count, singular)
622 } else {
623 format!("{} {}s", count, singular)
624 }
625}
626
627/// Format bytes in a human-readable way.
628///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected