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
sourceimpl ListFormatter
impl ListFormatter
sourcepub fn try_new_and_with_length_unstable<D>(
data_provider: &D,
locale: &DataLocale,
length: ListLength
) -> Result<ListFormatter, ListError> where
D: DataProvider<AndListV1Marker> + ?Sized,
pub fn try_new_and_with_length_unstable<D>(
data_provider: &D,
locale: &DataLocale,
length: ListLength
) -> Result<ListFormatter, ListError> where
D: DataProvider<AndListV1Marker> + ?Sized,
Creates a new ListFormatter
that produces a and-type list.
See the CLDR spec for an explanation of the different types.
sourcepub fn try_new_and_with_length_with_any_provider(
provider: &impl AnyProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
pub fn try_new_and_with_length_with_any_provider(
provider: &impl AnyProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
Creates a new instance using an AnyProvider
.
For details on the behavior of this function, see: Self::try_new_and_with_length_unstable
sourcepub fn try_new_and_with_length_with_buffer_provider(
provider: &impl BufferProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
pub fn try_new_and_with_length_with_buffer_provider(
provider: &impl BufferProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
✨ 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
sourcepub fn try_new_or_with_length_unstable<D>(
data_provider: &D,
locale: &DataLocale,
length: ListLength
) -> Result<ListFormatter, ListError> where
D: DataProvider<OrListV1Marker> + ?Sized,
pub fn try_new_or_with_length_unstable<D>(
data_provider: &D,
locale: &DataLocale,
length: ListLength
) -> Result<ListFormatter, ListError> where
D: DataProvider<OrListV1Marker> + ?Sized,
Creates a new ListFormatter
that produces a or-type list.
See the CLDR spec for an explanation of the different types.
sourcepub fn try_new_or_with_length_with_any_provider(
provider: &impl AnyProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
pub fn try_new_or_with_length_with_any_provider(
provider: &impl AnyProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
Creates a new instance using an AnyProvider
.
For details on the behavior of this function, see: Self::try_new_or_with_length_unstable
sourcepub fn try_new_or_with_length_with_buffer_provider(
provider: &impl BufferProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
pub fn try_new_or_with_length_with_buffer_provider(
provider: &impl BufferProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
✨ 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
sourcepub fn try_new_unit_with_length_unstable<D>(
data_provider: &D,
locale: &DataLocale,
length: ListLength
) -> Result<ListFormatter, ListError> where
D: DataProvider<UnitListV1Marker> + ?Sized,
pub fn try_new_unit_with_length_unstable<D>(
data_provider: &D,
locale: &DataLocale,
length: ListLength
) -> Result<ListFormatter, ListError> where
D: DataProvider<UnitListV1Marker> + ?Sized,
Creates a new ListFormatter
that produces a unit-type list.
See the CLDR spec for an explanation of the different types.
sourcepub fn try_new_unit_with_length_with_any_provider(
provider: &impl AnyProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
pub fn try_new_unit_with_length_with_any_provider(
provider: &impl AnyProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
Creates a new instance using an AnyProvider
.
For details on the behavior of this function, see: Self::try_new_unit_with_length_unstable
sourcepub fn try_new_unit_with_length_with_buffer_provider(
provider: &impl BufferProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
pub fn try_new_unit_with_length_with_buffer_provider(
provider: &impl BufferProvider,
locale: &DataLocale,
style: ListLength
) -> Result<ListFormatter, ListError>
✨ 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
sourcepub fn format<'a, W, I>(&'a self, values: I) -> FormattedList<'a, W, I> where
W: 'a + Writeable,
I: 'a + Iterator<Item = W> + Clone,
pub fn format<'a, W, I>(&'a self, values: I) -> FormattedList<'a, W, I> where
W: 'a + Writeable,
I: 'a + Iterator<Item = W> + Clone,
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_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),
]
);
Auto Trait Implementations
impl RefUnwindSafe for ListFormatter
impl Send for ListFormatter
impl Sync for ListFormatter
impl Unpin for ListFormatter
impl UnwindSafe for ListFormatter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more