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
type Output
The resulting type after concatenation
fn concat(&self) -> Self::Output
Flattens a slice of T
into a single value Self::Output
.
assert_eq!(["hello", "world"].concat(), "helloworld"); assert_eq!([[1, 2], [3, 4]].concat(), [1, 2, 3, 4]);
fn join(&self, sep: &T) -> Self::Output
Flattens a slice of T
into a single value Self::Output
, placing a given separator between each.
assert_eq!(["hello", "world"].join(" "), "hello world"); assert_eq!([[1, 2], [3, 4]].join(&0), [1, 2, 0, 3, 4]);
fn connect(&self, sep: &T) -> Self::Output
impl<T, V> SliceConcatExt<T> for [V] where
T: Clone,
V: Borrow<[T]>, type Output = Vec<T>;
impl<S> SliceConcatExt<str> for [S] where
S: Borrow<str>, type Output = String;
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/slice/trait.SliceConcatExt.html