1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/// Matched fields logic with type conversions
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)]
pub struct MatchedFields(Vec<String>);

impl<T, const N: usize> From<[T; N]> for MatchedFields
where
    T: ToString,
{
    fn from(values: [T; N]) -> Self {
        Self(values.iter().map(ToString::to_string).collect())
    }
}

impl<T> From<Vec<T>> for MatchedFields
where
    T: ToString,
{
    fn from(values: Vec<T>) -> Self {
        Self(values.iter().map(ToString::to_string).collect())
    }
}

impl<'a, T> From<&'a [T]> for MatchedFields
where
    T: ToString,
{
    fn from(values: &'a [T]) -> Self {
        Self(values.iter().map(ToString::to_string).collect())
    }
}