In C ++ 11, you can decompose a generic type into a value type by removing the semantics of reference / rvalue and cv qualifiers, for example.
decay<int>::type
decay<const int&>::type
decay<int&&>::type
Is there a known mechanism to achieve the same in Rust that separates reference modifiers, lifetimes, and qualifiers mut? eg:.
decay<u32>::type <--- type is `u32`
decay<&u32>::type <--- type is `u32`
decay<&mut u32>::type <--- type is `u32`
decay<&static u32>::type <--- type is `u32`
In the background, I am trying to write a macro that generates struct, which stores the values of a bunch of function arguments matched by the macro. for example, a macro may contain arguments foo: i32, bar: &Vec<String>, and the resulting structure should be:
struct GeneratedStruct {
foo: i32,
bar: Vec<String>,
}
source
share