pub struct Separators { /* private fields */ }Expand description
Displays a sequence of elements as comma separated list with a final separator.
§Examples
assert_eq!(
Separators::new(", ", " or ").with(&["a", "b", "c"]).to_string(),
"a, b or c",
);
assert_eq!(
Separators::comma_or().with(&["a", "b", "c"]).to_string(),
"a, b or c",
);Implementations§
Source§impl Separators
impl Separators
Sourcepub fn new(
separator: &'static str,
terminal_separator: impl Into<Option<&'static str>>,
) -> Self
pub fn new( separator: &'static str, terminal_separator: impl Into<Option<&'static str>>, ) -> Self
Creates a new sequence to display.
§Examples
assert_eq!(
Separators::new("-", None).with(["a", "b", "c"]).to_string(),
"a-b-c",
);
assert_eq!(
Separators::new("-", "/").with(["a", "b", "c"]).to_string(),
"a-b/c",
);Sourcepub fn comma() -> Self
pub fn comma() -> Self
Creates a new sequence to display using only , as separator.
§Examples
assert_eq!(
Separators::comma().with(["a", "b"]).to_string(),
"a, b",
);
assert_eq!(
Separators::comma().with(["a", "b", "c"]).to_string(),
"a, b, c",
);Sourcepub fn comma_or() -> Self
pub fn comma_or() -> Self
Creates a new sequence to display using , and or as the separators.
§Examples
assert_eq!(
Separators::comma_or().with(["a", "b"]).to_string(),
"a or b",
);
assert_eq!(
Separators::comma_or().with(["a", "b", "c"]).to_string(),
"a, b or c",
);Sourcepub fn comma_and() -> Self
pub fn comma_and() -> Self
Creates a new sequence to display using , and and as the separators.
§Examples
assert_eq!(
Separators::comma_and().with(["a", "b"]).to_string(),
"a and b",
);
assert_eq!(
Separators::comma_and().with(["a", "b", "c"]).to_string(),
"a, b and c",
);Trait Implementations§
Source§impl Clone for Separators
impl Clone for Separators
Source§fn clone(&self) -> Separators
fn clone(&self) -> Separators
Returns a copy of the value. Read more
1.0.0 · 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 Separators
impl Debug for Separators
Source§impl Hash for Separators
impl Hash for Separators
Source§impl PartialEq for Separators
impl PartialEq for Separators
impl Copy for Separators
impl Eq for Separators
impl StructuralPartialEq for Separators
Auto Trait Implementations§
impl Freeze for Separators
impl RefUnwindSafe for Separators
impl Send for Separators
impl Sync for Separators
impl Unpin for Separators
impl UnwindSafe for Separators
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