1 | use alloc::string::String; |
2 | use core::borrow::Borrow; |
3 | |
4 | use crate::{TiSlice, TiVec}; |
5 | |
6 | /// A helper trait for [`TiSlice::concat`](crate::TiSlice#method.concat). |
7 | pub trait Concat<Item: ?Sized> { |
8 | /// The resulting type after concatenation |
9 | type Output; |
10 | |
11 | /// Implementation of [`TiSlice::concat`](crate::TiSlice#method.concat) |
12 | fn concat(slice: &Self) -> Self::Output; |
13 | } |
14 | |
15 | impl<K, V: Borrow<str>> Concat<str> for TiSlice<K, V> { |
16 | type Output = String; |
17 | |
18 | #[inline ] |
19 | fn concat(slice: &Self) -> Self::Output { |
20 | slice.raw.concat() |
21 | } |
22 | } |
23 | |
24 | impl<K, T: Clone, V: Borrow<[T]>> Concat<T> for TiSlice<K, V> { |
25 | type Output = TiVec<K, T>; |
26 | |
27 | #[inline ] |
28 | fn concat(slice: &Self) -> Self::Output { |
29 | slice.raw.concat().into() |
30 | } |
31 | } |
32 | |