1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Ordinal formatting.
//!
//! Use this module for locale-aware ordinal markers such as `1st`, `21.` or `42-й`.
//!
//! # Quick start
//!
//! ```rust
//! use humfmt::{ordinal, ordinal_with};
//!
//! assert_eq!(ordinal(1).to_string(), "1st");
//! assert_eq!(ordinal(21).to_string(), "21st");
//! assert_eq!(ordinal(11).to_string(), "11th");
//! ```
//!
//! # Edge case behaviour
//!
//! | Input | English | Russian | Polish |
//! |---:|---|---|---|
//! | `1` | `"1st"` | `"1-й"` | `"1."` |
//! | `2` | `"2nd"` | `"2-й"` | `"2."` |
//! | `11` | `"11th"` | `"11-й"` | `"11."` |
//! | `21` | `"21st"` | `"21-й"` | `"21."` |
//! | `103` | `"103rd"` | `"103-й"` | `"103."` |
//! | `111` | `"111th"` | `"111-й"` | `"111."` |
//! | `-1` | `"-1st"` | `"-1-й"` | `"-1."` |
//!
//! # Limitations
//!
//! **Russian gender:** The Russian ordinal suffix is always `-й` (masculine).
//! The library has no concept of grammatical gender since it only receives a
//! number. If you need feminine or neuter ordinals in Russian, you must handle
//! that outside the formatter.
pub use OrdinalDisplay;
pub use OrdinalLike;
use crate;
/// Creates a human-readable ordinal formatter using the default English locale.
///
/// # Examples
///
/// ```rust
/// assert_eq!(humfmt::ordinal(1).to_string(), "1st");
/// assert_eq!(humfmt::ordinal(23).to_string(), "23rd");
/// ```
/// Creates a human-readable ordinal formatter with a custom locale.
///
/// # Examples
///
/// ```rust
/// use humfmt::locale::English;
///
/// let out = humfmt::ordinal_with(11, English);
/// assert_eq!(out.to_string(), "11th");
/// ```