I'm working with recursive enums in Rust. I have the following code:
enum Rdd<T, G, H> where G: (Fn(&T) -> H), { Data(Vec<T>), Map(G, Box<Rdd<T, G, H>>) } fn main() { let mut v1: Vec<u32> = vec![1, 2, 3, 4, 5, 6]; let rdd_1 = Rdd::Data(v1); // It does not work } When I try to compile It throws:
let rdd_1 = Rdd::Data(v1); // It does not work ^^^^^^^^^ cannot infer type for `G` consider giving `rdd_1` the explicit type `Rdd<u32, G, H>`, where the type parameter `G` is specified Why should I provide a type for G parameter as It's not needed for the Rdd::Data enum? How could I solve this problem?
Thanks in advance