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

Function format_count

atomic-cli/src/commands/pull/helpers.rs:413–419  ·  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::pull::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

411/// assert_eq!(format_count(5, "change"), "5 changes");
412/// ```
413pub fn format_count(count: usize, singular: &str) -> String {
414 if count == 1 {
415 format!("{} {}", count, singular)
416 } else {
417 format!("{} {}s", count, singular)
418 }
419}
420
421/// Format bytes in a human-readable way.
422///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected