pub fn convert_vec_to_slice(vec: &[(String, String, String)]) -> Vec<(&str, &str, &str)> {
vec.iter()
.map(|(a, b, c)| (a.as_str(), b.as_str(), c.as_str()))
.collect()
}
#[macro_export]
macro_rules! vec_to_slice {
($vec:expr) => {
&convert_vec_to_slice(&$vec)[..]
};
}
pub use vec_to_slice;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_convert_vec_of_string_to_vec_of_str_slice() {
let vec_of_strings = vec![
(
String::from("date"),
String::from("="),
String::from("2022-01-02"),
),
(
String::from("foo"),
String::from("bar"),
String::from("baz"),
),
];
let expected_slice = vec![("date", "=", "2022-01-02"), ("foo", "bar", "baz")];
let result = vec_to_slice!(&vec_of_strings);
assert_eq!(result, expected_slice);
}
}