pub struct Once<T>(pub T);
Expand description
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.
}
Tuple Fields§
§0: T
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Once<T>where
T: Freeze,
impl<T> RefUnwindSafe for Once<T>where
T: RefUnwindSafe,
impl<T> Send for Once<T>where
T: Send,
impl<T> Sync for Once<T>where
T: Sync,
impl<T> Unpin for Once<T>where
T: Unpin,
impl<T> UnwindSafe for Once<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more