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
67
68
69
70
71
//! Natural-language list formatting.
//!
//! # Quick start
//!
//! ```rust
//! use humfmt::{list, list_with, ListOptions};
//!
//! // Default: Oxford comma
//! assert_eq!(list(&["red", "green", "blue"]).to_string(), "red, green, and blue");
//!
//! // No serial comma
//! let no_oxford = list_with(
//! &["red", "green", "blue"],
//! ListOptions::new().no_serial_comma(),
//! );
//! assert_eq!(no_oxford.to_string(), "red, green and blue");
//! ```
//!
//! # Edge case behaviour
//!
//! | Input | Default output | Notes |
//! |---:|---|---|
//! | `[]` | `""` | Empty list |
//! | `["red"]` | `"red"` | Single item |
//! | `["red", "green"]` | `"red and green"` | Two items, no comma |
//! | `["red", "green", "blue"]` | `"red, green, and blue"` | Three items, serial comma |
//!
//! # Serial comma and non-comma separators
//!
//! The serial comma (Oxford comma) is only meaningful for comma-style separators.
//! If you override the list separator to something non-comma-like (e.g. `" | "`),
//! `humfmt` will not inject a literal comma before the final conjunction even if
//! serial comma is enabled. This keeps the output predictable.
pub use ListDisplay;
pub use ListOptions;
/// Creates a natural-language list formatter using default options.
///
/// # Examples
///
/// ```rust
/// let out = humfmt::list(&["red", "green", "blue"]);
/// assert_eq!(out.to_string(), "red, green, and blue");
/// ```
/// Creates a natural-language list formatter with custom options.
///
/// # Examples
///
/// ```rust
/// use humfmt::{list_with, ListOptions};
///
/// let out = list_with(
/// &["red", "green", "blue"],
/// ListOptions::new()
/// .serial_comma_enabled(false)
/// .conjunction("plus"),
/// );
/// assert_eq!(out.to_string(), "red, green plus blue");
/// ```