Several things happen here, and all this is due to a little awkwardness around the semantics of movement and closure.
-, simple T. T , , , . Lifetime elision , . 'static, . , lifetime; . .
Fn, . , , , , (a) . , , , self &self. , :
trait FnOnce {
type Output
fn call(self) -> Output
}
trait Fn : FnOnce {
fn call(&self) -> Output
}
struct MyClosure<T> {
a: T
}
impl<T> FnOnce for MyClosure<T> {
fn call(self) -> T { self.a }
}
( , .)
, , , Fn, FnOnce. . FnMut, .
, . , , , self - (Box<T>, T ). , , . , . Box<FnOnce>. ( self), .
, ? Box<FnOnce> . .
Rust, FnBox: FnOnce, Box. , , : " , FnBox , Box<FnOnce()> ". , , , .
, , .
&'static T, . , , , .
, Rc<T>. - , , , . , .
. , , , . . , Rc<T> T, , .