Hey guys,
Having some problems getting an enum destructured into a generic struct:
struct Z<T> {
v: Box<T>,
}
impl<T> Z<T> {
fn new(input: Box<T>) > Z<T> {
Z { v: input }
}
}
enum A {
B(Box<bool>),
C(Box<u32>),
}
// A > Z<T>
fn convert<T>(input: A) > Z<T> {
match input {
A::B(x) => Z::new(x),
A::C(y) => Z::new(y),
}
}
Which gives back the errors:
error[E0308]: mismatched types
> src/test.rs:102:23

102  A::B(x) => Z::new(x),
 ^ expected type parameter, found bool

= note: expected type `std::boxed::Box<T>`
found type `std::boxed::Box<bool>`
error[E0308]: mismatched types
> src/test.rs:103:23

103  A::C(y) => Z::new(y),
 ^ expected type parameter, found u32

= note: expected type `std::boxed::Box<T>`
found type `std::boxed::Box<u32>`
Where I expected that T be applicable here to both u32 and bool. What is the standard way of converting from an enum like this into a generic struct?