Hi, I'm beginner to rust. Can any one explain why this snippet doesn't work? and what's the best practice to do the same thing?
struct Foo where F: FnOnce() {
f: F,
}
impl<T> Foo<T> where T: FnOnce() {
fn new(f: T) -> Self {
Foo {
f
}
}
}
impl<F> Drop for Foo<F> where F: FnOnce() {
fn drop(&mut self) {
let y = self.f; //error: cannot move
y();
}
}