pub struct ListFormatter { /* private fields */ }
Expand description

A formatter that renders sequences of items in an i18n-friendly way. See the crate-level documentation for more details.

Implementations

Creates a new ListFormatter that produces a and-type list.

See the CLDR spec for an explanation of the different types.

📚 Help choosing a constructor

⚠️ The bounds on this function may change over time, including in SemVer minor releases.

Creates a new instance using an AnyProvider.

For details on the behavior of this function, see: Self::try_new_and_with_length_unstable

📚 Help choosing a constructor

Enabled with the "serde" feature.

Creates a new instance using a BufferProvider.

For details on the behavior of this function, see: Self::try_new_and_with_length_unstable

📚 Help choosing a constructor

Creates a new ListFormatter that produces a or-type list.

See the CLDR spec for an explanation of the different types.

📚 Help choosing a constructor

⚠️ The bounds on this function may change over time, including in SemVer minor releases.

Creates a new instance using an AnyProvider.

For details on the behavior of this function, see: Self::try_new_or_with_length_unstable

📚 Help choosing a constructor

Enabled with the "serde" feature.

Creates a new instance using a BufferProvider.

For details on the behavior of this function, see: Self::try_new_or_with_length_unstable

📚 Help choosing a constructor

Creates a new ListFormatter that produces a unit-type list.

See the CLDR spec for an explanation of the different types.

📚 Help choosing a constructor

⚠️ The bounds on this function may change over time, including in SemVer minor releases.

Creates a new instance using an AnyProvider.

For details on the behavior of this function, see: Self::try_new_unit_with_length_unstable

📚 Help choosing a constructor

Enabled with the "serde" feature.

Creates a new instance using a BufferProvider.

For details on the behavior of this function, see: Self::try_new_unit_with_length_unstable

📚 Help choosing a constructor

Returns a Writeable composed of the input Writeables and the language-dependent formatting.

The Writeable is annotated with parts::ELEMENT for input elements, and parts::LITERAL for list literals.

Example
use icu::list::*;
let formatteur = ListFormatter::try_new_and_with_length_unstable(&icu_testdata::unstable(), &locale!("fr").into(), ListLength::Wide).unwrap();
let pays = ["Italie", "France", "Espagne", "Allemagne"];

assert_writeable_parts_eq!(
    formatteur.format(pays.iter()),
    "Italie, France, Espagne et Allemagne",
    [
        (0, 6, parts::ELEMENT),
        (6, 8, parts::LITERAL),
        (8, 14, parts::ELEMENT),
        (14, 16, parts::LITERAL),
        (16, 23, parts::ELEMENT),
        (23, 27, parts::LITERAL),
        (27, 36, parts::ELEMENT),
    ]
);

Returns a String composed of the input Writeables and the language-dependent formatting.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.