Trait std::slice::SliceConcatExt
[−]
[src]
pub trait SliceConcatExt<T> where T: ?Sized {
type Output;
fn concat(&self) -> Self::Output;
fn join(&self, sep: &T) -> Self::Output;
fn connect(&self, sep: &T) -> Self::Output;
}
An extension trait for concatenating slices
Associated Types
type Output
The resulting type after concatenation
Required Methods
fn concat(&self) -> Self::Output
Flattens a slice of T
into a single value Self::Output
.
Examples
fn main() { assert_eq!(["hello", "world"].concat(), "helloworld"); }assert_eq!(["hello", "world"].concat(), "helloworld");
fn join(&self, sep: &T) -> Self::Output
Flattens a slice of T
into a single value Self::Output
, placing a
given separator between each.
Examples
fn main() { assert_eq!(["hello", "world"].join(" "), "hello world"); }assert_eq!(["hello", "world"].join(" "), "hello world");
fn connect(&self, sep: &T) -> Self::Output
Deprecated since 1.3.0
: renamed to join
Flattens a slice of T
into a single value Self::Output
, placing a
given separator between each.
Examples
fn main() { #![allow(deprecated)] assert_eq!(["hello", "world"].connect(" "), "hello world"); }assert_eq!(["hello", "world"].connect(" "), "hello world");
Implementors
impl<T, V> SliceConcatExt<T> for [V] where V: Borrow<[T]>, T: Clone
impl<S> SliceConcatExt<str> for [S] where S: Borrow<str>