joinery::join

Trait Separator

Source
pub trait Separator: Sized {
    // Provided method
    fn separate<T: Joinable>(self, collection: T) -> Join<T::Collection, Self> { ... }
}
Expand description

A trait for using a separator to produce a Join.

This trait provides a more python-style interface for performing joins. Rather use collection.join_with, you can instead use:

use joinery::Separator;

let join = ", ".separate([1, 2, 3, 4]);
assert_eq!(join.to_string(), "1, 2, 3, 4");

By default, Separator is implemented for char and &str, as well as all the separator types in separators.

Note that any type can be used as a separator in a Join when creating one via Joinable::join_with. The Separator trait and its implementations on char and &str are provided simply as a convenience.

Provided Methods§

Source

fn separate<T: Joinable>(self, collection: T) -> Join<T::Collection, Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Separator for char

Source§

impl<'a> Separator for &'a str

Implementors§