mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-01 18:01:06 +00:00
Merge pull request #809 from Tarnadas/master
doc: Add nightly feature hint for closures
This commit is contained in:
commit
8124cffeba
@ -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
|
For this scenario, you need the `Closure` type, which is defined in the
|
||||||
`wasm_bindgen` crate, exported in `wasm_bindgen::prelude`, and represents a
|
`wasm_bindgen` crate, exported in `wasm_bindgen::prelude`, and represents a
|
||||||
"long lived" closure.
|
"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`
|
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
|
in Rust. **Once a `Closure` is dropped, it will deallocate its internal memory
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
//! This module defines the `Closure` type which is used to pass "owned
|
//! 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`
|
//! closures" from Rust to JS. Some more details can be found on the `Closure`
|
||||||
//! type itself.
|
//! type itself.
|
||||||
|
//!
|
||||||
|
//! The `nightly` feature is required for the `Closure` type to be used.
|
||||||
|
|
||||||
use std::cell::UnsafeCell;
|
use std::cell::UnsafeCell;
|
||||||
#[cfg(feature = "nightly")]
|
#[cfg(feature = "nightly")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user