typed_index_collections/slice/
concat.rs

1use alloc::string::String;
2use core::borrow::Borrow;
3
4use crate::{TiSlice, TiVec};
5
6/// A helper trait for [`TiSlice::concat`](crate::TiSlice#method.concat).
7pub 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
15impl<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
24impl<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}