Skip to main content

Module list

Module list 

Source
Expand description

Locale-aware list formatting (CLDR / UTS #35): joining items with the right connectors, e.g. "a, b, and c" (English “and”) or "a, b o c" (Spanish “or”). Requires the alloc feature.

use intl::list::{format_list, ListStyle};
assert_eq!(format_list("en", &["a", "b", "c"], ListStyle::And), "a, b, and c");
assert_eq!(format_list("en", &["a", "b"], ListStyle::Or), "a or b");
assert_eq!(format_list("de", &["a", "b", "c"], ListStyle::And), "a, b und c");

Structs§

ListPatterns
The four CLDR list connector patterns (each contains {0} and {1}).
ListSpec
The list patterns for one locale (both styles).

Enums§

ListStyle
Whether a list is conjunctive (“and”) or disjunctive (“or”).

Functions§

format_list
Join items into a single string using the list conventions of lang.