gapirs-common 0.0.1

Common library for gapirs
Documentation
pub trait ConvertToQueryParams {
    fn to_google_param_str(&self) -> String;
}

/// Generates an implementation that just does to_string() on the value.
///
/// It was not automatically implemented for anything that implements Display or ToString
/// because something other than what is defined here is probably a bug and might lead to some
/// other Problems, so I tried to catch these early.
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);
    }
}