From e6fe9cf35336d73a84e8bfde7f72862a5b5d53af Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Tue, 11 Sep 2018 07:02:16 +0200 Subject: [PATCH] doc: Add nightly feature hint for closures resolves #767 --- guide/src/reference/passing-rust-closures-to-js.md | 6 ++++++ src/closure.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/guide/src/reference/passing-rust-closures-to-js.md b/guide/src/reference/passing-rust-closures-to-js.md index fc09fce4..2753c717 100644 --- a/guide/src/reference/passing-rust-closures-to-js.md +++ b/guide/src/reference/passing-rust-closures-to-js.md @@ -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 diff --git a/src/closure.rs b/src/closure.rs index 910e6ac6..ba9612de 100644 --- a/src/closure.rs +++ b/src/closure.rs @@ -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")]