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§
Source§impl ListFormatter
 
impl ListFormatter
Sourcepub fn try_new_and(
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_and( prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
Creates a new ListFormatter that produces a and-type list using compiled data.
See the CLDR spec for an explanation of the different types.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn try_new_and_with_buffer_provider(
    provider: &(impl BufferProvider + ?Sized),
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_and_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_and] that uses custom data provided by a BufferProvider.
✨ Enabled with the serde feature.
Sourcepub fn try_new_and_unstable(
    provider: &(impl DataProvider<ListAndV1> + ?Sized),
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_and_unstable( provider: &(impl DataProvider<ListAndV1> + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_and] that uses custom data provided by a DataProvider.
Sourcepub fn try_new_or(
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_or( prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
Creates a new ListFormatter that produces a or-type list using compiled data.
See the CLDR spec for an explanation of the different types.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn try_new_or_with_buffer_provider(
    provider: &(impl BufferProvider + ?Sized),
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_or_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_or] that uses custom data provided by a BufferProvider.
✨ Enabled with the serde feature.
Sourcepub fn try_new_or_unstable(
    provider: &(impl DataProvider<ListOrV1> + ?Sized),
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_or_unstable( provider: &(impl DataProvider<ListOrV1> + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_or] that uses custom data provided by a DataProvider.
Sourcepub fn try_new_unit(
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_unit( prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
Creates a new ListFormatter that produces a unit-type list using compiled data.
See the CLDR spec for an explanation of the different types.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn try_new_unit_with_buffer_provider(
    provider: &(impl BufferProvider + ?Sized),
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_unit_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_unit] that uses custom data provided by a BufferProvider.
✨ Enabled with the serde feature.
Sourcepub fn try_new_unit_unstable(
    provider: &(impl DataProvider<ListUnitV1> + ?Sized),
    prefs: ListFormatterPreferences,
    options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
 
pub fn try_new_unit_unstable( provider: &(impl DataProvider<ListUnitV1> + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_unit] that uses custom data provided by a DataProvider.
Sourcepub fn format<'a, W, I>(&'a self, values: I) -> FormattedList<'a, W, I>
 
pub fn format<'a, W, I>(&'a self, values: I) -> FormattedList<'a, W, I>
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::options::*;
use icu::list::{parts, ListFormatter};
let formatteur = ListFormatter::try_new_and(
    locale!("fr").into(),
    ListFormatterOptions::default().with_length(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),
    ]
);Trait Implementations§
Auto Trait Implementations§
impl Freeze for ListFormatter
impl RefUnwindSafe for ListFormatter
impl !Send for ListFormatter
impl !Sync for ListFormatter
impl Unpin for ListFormatter
impl UnwindSafe for ListFormatter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more