Closed
Description
This,
/// A binary tree with nodes labelled with `T`
pub struct Tree<T> {
pub value: T,
pub left: Option<Box<Tree<T>>>,
pub right: Option<Box<Tree<T>>>,
}
impl<T> Tree<T> {
pub fn map_step<F, V>(self, f: &mut FnMut(T) -> V) -> Tree<V> {
Tree {
left: self.left.map(|x| { let a: Tree<V> = x.map_step(f);
Box::new(a) }),
right: self.right.map(|x| Box::new(x.map_step(f))),
value: f(self.value),
}
}
}
fn main() {}
fails with,
hi.rs:12:58: 12:69 error: unable to infer enough type information about `_`; type annotations required [E0282]
hi.rs:12 left: self.left.map(|x| { let a: Tree<V> = x.map_step(f);
^~~~~~~~~~~
All of my attempts at helping the compiler find the right types have failed, therefore I suspect it's a bug.
Metadata
Metadata
Assignees
Labels
No labels