pub struct ListOptions { /* private fields */ }Expand description
Builder-style configuration for list formatting.
humfmt list formatting is intentionally minimal and predictable:
it joins slices into natural-language lists with optional overrides.
§Examples
use humfmt::ListOptions;
let opts = ListOptions::new()
.serial_comma_enabled(false)
.conjunction("plus");
assert_eq!(
humfmt::list_with(&["red", "green", "blue"], opts).to_string(),
"red, green plus blue"
);Implementations§
Source§impl ListOptions
impl ListOptions
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates default list formatting options.
Defaults:
- serial comma: enabled (Oxford comma)
- conjunction:
"and" - separator:
", "
Sourcepub const fn serial_comma(self) -> Self
pub const fn serial_comma(self) -> Self
Enables the serial comma before the final list item.
Equivalent to .serial_comma_enabled(true).
Sourcepub const fn serial_comma_enabled(self, enabled: bool) -> Self
pub const fn serial_comma_enabled(self, enabled: bool) -> Self
Configures serial-comma behavior with an explicit boolean.
true:"a, b, and c"false:"a, b and c"
Sourcepub const fn no_serial_comma(self) -> Self
pub const fn no_serial_comma(self) -> Self
Disables the serial comma before the final list item.
Equivalent to .serial_comma_enabled(false).
Sourcepub const fn conjunction(self, word: &'static str) -> Self
pub const fn conjunction(self, word: &'static str) -> Self
Overrides the conjunction used to join the final list item.
Default is "and".
Example: "plus" produces "a, b plus c".
Trait Implementations§
Source§impl Clone for ListOptions
impl Clone for ListOptions
Source§fn clone(&self) -> ListOptions
fn clone(&self) -> ListOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ListOptions
impl Debug for ListOptions
Source§impl Default for ListOptions
impl Default for ListOptions
impl Copy for ListOptions
Auto Trait Implementations§
impl Freeze for ListOptions
impl RefUnwindSafe for ListOptions
impl Send for ListOptions
impl Sync for ListOptions
impl Unpin for ListOptions
impl UnsafeUnpin for ListOptions
impl UnwindSafe for ListOptions
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Humanize for T
impl<T> Humanize for T
Source§fn human_bytes(self) -> BytesDisplaywhere
Self: BytesLike,
fn human_bytes(self) -> BytesDisplaywhere
Self: BytesLike,
Formats this value as a human-readable byte size using default options.
Source§fn human_bytes_with(self, options: BytesOptions) -> BytesDisplaywhere
Self: BytesLike,
fn human_bytes_with(self, options: BytesOptions) -> BytesDisplaywhere
Self: BytesLike,
Formats this value as a human-readable byte size using custom options.
Source§fn human_ago(self) -> AgoDisplaywhere
Self: DurationLike,
fn human_ago(self) -> AgoDisplaywhere
Self: DurationLike,
Formats this duration as relative time using default options.
Source§fn human_ago_with(self, options: DurationOptions) -> AgoDisplaywhere
Self: DurationLike,
fn human_ago_with(self, options: DurationOptions) -> AgoDisplaywhere
Self: DurationLike,
Formats this duration as relative time using custom duration options.
Source§fn human_duration(self) -> DurationDisplaywhere
Self: DurationLike,
fn human_duration(self) -> DurationDisplaywhere
Self: DurationLike,
Formats this duration using default options.
Source§fn human_duration_with(self, options: DurationOptions) -> DurationDisplaywhere
Self: DurationLike,
fn human_duration_with(self, options: DurationOptions) -> DurationDisplaywhere
Self: DurationLike,
Formats this duration using custom duration options.
Source§fn human_number(self) -> NumberDisplaywhere
Self: NumberLike,
fn human_number(self) -> NumberDisplaywhere
Self: NumberLike,
Formats this numeric value as a compact human-readable number using default options.
Source§fn human_number_with(self, options: NumberOptions) -> NumberDisplaywhere
Self: NumberLike,
fn human_number_with(self, options: NumberOptions) -> NumberDisplaywhere
Self: NumberLike,
Formats this numeric value as a compact human-readable number using custom options.
Source§fn human_ordinal(self) -> OrdinalDisplaywhere
Self: OrdinalLike,
fn human_ordinal(self) -> OrdinalDisplaywhere
Self: OrdinalLike,
Formats this value as an ordinal number.
Source§fn human_percent(self) -> PercentDisplaywhere
Self: PercentLike,
fn human_percent(self) -> PercentDisplaywhere
Self: PercentLike,
Formats this value as a human-readable percentage using default options. Read more
Source§fn human_percent_with(self, options: PercentOptions) -> PercentDisplaywhere
Self: PercentLike,
fn human_percent_with(self, options: PercentOptions) -> PercentDisplaywhere
Self: PercentLike,
Formats this value as a human-readable percentage using custom options.