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.
}

Trait Implementations

impl<T> Debug for Once<T>
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> Send for Once<T> where
    T: Send

impl<T> Sync for Once<T> where
    T: Sync