Merge pull request #809 from Tarnadas/master

doc: Add nightly feature hint for closures
This commit is contained in:
Nick Fitzgerald 2018-09-11 10:02:53 -07:00 committed by GitHub
commit 8124cffeba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -63,6 +63,12 @@ return but the JavaScript closure still needs to be valid!
For this scenario, you need the `Closure` type, which is defined in the
`wasm_bindgen` crate, exported in `wasm_bindgen::prelude`, and represents a
"long lived" closure.
The `Closure` type is currently behind a feature which needs to be enabled:
```toml
[dependencies]
wasm-bindgen = {version = "^0.2", features = ["nightly"]}
```
The validity of the JavaScript closure is tied to the lifetime of the `Closure`
in Rust. **Once a `Closure` is dropped, it will deallocate its internal memory

View File

@ -3,6 +3,8 @@
//! This module defines the `Closure` type which is used to pass "owned
//! closures" from Rust to JS. Some more details can be found on the `Closure`
//! type itself.
//!
//! The `nightly` feature is required for the `Closure` type to be used.
use std::cell::UnsafeCell;
#[cfg(feature = "nightly")]