Trait joinery::Joinable [−][src]
pub trait Joinable { type IntoIter; fn join_with<S>(self, sep: S) -> Join<Self::IntoIter, S>; fn join_concat(self) -> Join<Self::IntoIter, NoSeparator>
where
Self: Sized, { ... } }
A trait for converting iterables and collections into Join
instances.
This trait is the primary way to create Join
instances. It is
implemented for all IntoIterator
types. See
join_with
for an example of its usage.
Associated Types
type IntoIter
The iterator type which will be used in the join.
Required Methods
fn join_with<S>(self, sep: S) -> Join<Self::IntoIter, S>
Combine this object with a separator to create a new Join
instance.
Note that the separator does not have to share the same type as the
iterator's values.
Examples
use joinery::Joinable; let parts = vec!["this", "is", "a", "sentence"]; let join = parts.iter().join_with(' '); assert_eq!(join.to_string(), "this is a sentence");
Provided Methods
fn join_concat(self) -> Join<Self::IntoIter, NoSeparator> where
Self: Sized,
Self: Sized,
Join this object an empty separator. When rendered
with Display
, the underlying elements will be directly concatenated.
Note that the separator, while empty, is still present, and will show
up if you iterate this instance.
Examples
use joinery::Joinable; let parts = vec!['a', 'b', 'c', 'd', 'e']; let join = parts.iter().join_concat(); assert_eq!(join.to_string(), "abcde");
New in 1.1.0
Implementors
impl<T: IntoIterator> Joinable for T type IntoIter = T::IntoIter;