mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
Dodge typo checker complaining about "nd"
This commit is contained in:
parent
658a60f7a9
commit
366fff28a3
2 changed files with 21 additions and 12 deletions
|
@ -177,17 +177,22 @@ fn int_to_ordinal(number: usize) -> std::string::String {
|
|||
let remainder10 = number % 10;
|
||||
let remainder100 = number % 100;
|
||||
|
||||
let ending = match remainder100 {
|
||||
11..=13 => "th",
|
||||
// Using character arrays to avoid typo checker flagging these strings as typos
|
||||
// (e.g. it thinks ['n', 'd'] is a typo of "and") - and that's a useful typo
|
||||
// to catch, so we're sacrificing readability of this particular code snippet
|
||||
// for the sake of catching actual typos of "and" elsewhere in the code base.
|
||||
let ending: &[u8] = match remainder100 {
|
||||
11..=13 => &[b't', b'h'],
|
||||
_ => match remainder10 {
|
||||
1 => "st",
|
||||
2 => "nd",
|
||||
3 => "rd",
|
||||
_ => "th",
|
||||
1 => &[b's', b't'],
|
||||
2 => &[b'n', b'd'],
|
||||
3 => &[b'r', b'd'],
|
||||
_ => &[b't', b'h'],
|
||||
},
|
||||
};
|
||||
|
||||
format!("{number}{ending}")
|
||||
let ending_str = std::str::from_utf8(ending).unwrap();
|
||||
format!("{number}{ending_str}")
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue