Struct icu::list::ListFormatter
source · 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_any_provider(
provider: &(impl AnyProvider + ?Sized),
prefs: ListFormatterPreferences,
options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
pub fn try_new_and_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_and
] that uses custom data provided by an AnyProvider
.
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<AndListV2Marker> + ?Sized),
prefs: ListFormatterPreferences,
options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
pub fn try_new_and_unstable( provider: &(impl DataProvider<AndListV2Marker> + ?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_any_provider(
provider: &(impl AnyProvider + ?Sized),
prefs: ListFormatterPreferences,
options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
pub fn try_new_or_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_or
] that uses custom data provided by an AnyProvider
.
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<OrListV2Marker> + ?Sized),
prefs: ListFormatterPreferences,
options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
pub fn try_new_or_unstable( provider: &(impl DataProvider<OrListV2Marker> + ?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_any_provider(
provider: &(impl AnyProvider + ?Sized),
prefs: ListFormatterPreferences,
options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
pub fn try_new_unit_with_any_provider( provider: &(impl AnyProvider + ?Sized), prefs: ListFormatterPreferences, options: ListFormatterOptions, ) -> Result<ListFormatter, DataError>
A version of [Self :: try_new_unit
] that uses custom data provided by an AnyProvider
.
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<UnitListV2Marker> + ?Sized),
prefs: ListFormatterPreferences,
options: ListFormatterOptions,
) -> Result<ListFormatter, DataError>
pub fn try_new_unit_unstable( provider: &(impl DataProvider<UnitListV2Marker> + ?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 Writeable
s 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(
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