Format a count with singular/plural noun.
(count: usize, singular: &str, plural: &str)
| 543 | |
| 544 | /// Format a count with singular/plural noun. |
| 545 | fn format_count(count: usize, singular: &str, plural: &str) -> String { |
| 546 | if count == 1 { |
| 547 | format!("{} {}", count, singular) |
| 548 | } else { |
| 549 | format!("{} {}", count, plural) |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | // Tests |
| 554 |