Calling associated fuction on a complex type
I want to write T::associated_function(..) but sometimes T is too verbose to write, like a long tuple.
Is there any way to avoid writing the full T?
pub trait Param {
fn encode_type(out: &mut Vec);
}
pub trait Params {
fn encode_type(out: &mut Vec);
}
// Some macros to extend the implementation for long tuples
impl_params_for_tuple!(T0: 0);
impl_params_for_tuple!(T0: 0, T1: 1);
impl_params_for_tuple!(T0: 0, T1: 1, T2: 2);
impl_params_for_tuple!(T0: 0, T1: 1, T2: 2, T3: 3);
..
fn test_params_mixed_types() {
let mut buffer = Vec::new();
let params = (
1i8, 2i16, 3i32, 4i64, 5u8, 6u16, 7u32, 8u64, 1.5f32, 2.5f64, "hello",
);
// want to write something like `type_of(params)::encode_types`
<(i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, &str)>::encode_types(&mut buffer);
assert_eq!(types.len(), 22);
}