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

Function format_count

atomic-cli/tests/fixtures/helpers_c6.rs:499–505  ·  view source on GitHub ↗

Format a count with singular/plural suffix. # Arguments `count` - The count to format `singular` - The singular form of the word # Returns A formatted string like "1 change" or "5 changes". # Example ```rust,ignore assert_eq!(format_count(1, "change"), "1 change"); assert_eq!(format_count(5, "change"), "5 changes"); ```

(count: usize, singular: &str)

Source from the content-addressed store, hash-verified

497/// assert_eq!(format_count(5, "change"), "5 changes");
498/// ```
499pub fn format_count(count: usize, singular: &str) -> String {
500 if count == 1 {
501 format!("{} {}", count, singular)
502 } else {
503 format!("{} {}s", count, singular)
504 }
505}
506
507// Tests
508

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected