stylish_stringlike/text/
joinable.rs

1/// Provides functionality for joining text objects together.
2pub trait Joinable<T> {
3    type Output: Sized;
4    /// Join an object to another object, returning an owned copy.
5    ///
6    /// # Example
7    /// ```
8    /// use stylish_stringlike::text::Joinable;
9    /// let foo = String::from("foo");
10    /// let bar = String::from("bar");
11    /// assert_eq!(foo.join(&bar), String::from("foobar"));
12    /// ```
13    fn join(&self, other: &T) -> Self::Output;
14}
15
16impl Joinable<String> for String {
17    type Output = String;
18    fn join(&self, other: &String) -> Self::Output {
19        [self, other].iter().map(|x| x.as_str()).collect::<String>()
20    }
21}