macro_rules! ordinal {
(first $($ty:ident)?) => { ... };
(second $($ty:ident)?) => { ... };
(third $($ty:ident)?) => { ... };
($n:literal $(-)? $suffix:ident $($ty:ident)?) => { ... };
($n:literal . $($ty:ident)?) => { ... };
}Expand description
Creates a 1-based ordinal number. Examples:
use num_ordinal::{O32, ordinal};
let mut o: O32 = ordinal!(first);
o = ordinal!(second);
o = ordinal!(third);
// Other numbers must use the following syntax:
o = ordinal!(4-th);
// the dash can be omitted, but then a space is required to make the Rust parser happy:
o = ordinal!(4 th);
// alternatively, a dot can be written after the number:
o = ordinal!(4 .);
// When necessary, the type can be ascribed:
let o = ordinal!(5-th O32);Note that only first, second and third can be written as a full word:
ⓘ
use num_ordinal::{O32, ordinal};
// doesn't compile!
let _: O32 = ordinal!(fifth);