use std::collections::HashMap;
pub fn option_bool_to_int<T>(value: Option<bool>) -> T
where
i8: Into<T>,
T: Default + From<i8>,
{
match value {
Some(true) => 1.into(),
Some(false) => 0.into(),
None => T::default(),
}
}
pub fn option_map_to_str<T>(value: Option<HashMap<String, String>>) -> T
where
String: Into<T>,
T: Default + From<String>,
{
match value {
Some(map) => map
.into_iter()
.map(|(k, v)| format!("{}={}", k, v))
.collect::<String>()
.into(),
None => T::default(),
}
}