Struct stdweb::Once
[−]
[src]
pub struct Once<T>(pub T);
A wrapper for passing FnOnce
callbacks into the js!
macro.
Since it only supports FnOnce
callbacks there is no need to
drop()
them manually on the JavaScript side provided they
were actually called.
You still need to drop()
any callbacks which were not called.
Examples
let callback = || { println!( "Hello world!" ); }; js! { var cb = @{Once(callback)}; cb(); // There is no need to drop it; since the function // is only callable once it automatically drops // itself after being called. }