pub trait ConvertToQueryParams {
fn to_google_param_str(&self) -> String;
}
macro_rules! impl_convert_to_query_params_with_to_string {
(for $($t:ty),+) => {
$(
impl ConvertToQueryParams for $t {
fn to_google_param_str(&self) -> String {
self.to_string()
}
}
impl ConvertToQueryParams for & $t {
fn to_google_param_str(&self) -> String {
self.to_string()
}
}
)*
}
}
impl_convert_to_query_params_with_to_string!(for
bool,
u8, u16, u32, u64,
i8, i16, i32, i64,
f32, f64,
str, String
);
#[cfg(test)]
mod test {
use super::ConvertToQueryParams;
#[test]
fn hi() {
let x = 4u32.to_google_param_str();
assert_eq!("4", x);
}
}