Navigation Menu

Skip to content

Commit

Permalink
Implement AsRef<JsValue> for Closure<T>
Browse files Browse the repository at this point in the history
This commit adds an implementation of `AsRef<JsValue>` for the `Closure<T>`
type. Previously this was not possible because the `JsValue` didn't actually
exist until the closure was passed to JS, but the implementation has been
changed to ... something a bit more unconventional. The end result, however, is
that `Closure<T>` now always contains a `JsValue`.

The end result of this work is intended to be a precursor to binding callbacks
in `web-sys` as `JsValue` everywhere but still allowing usage with `Closure<T>`.
  • Loading branch information
alexcrichton committed Sep 6, 2018
1 parent cda7175 commit 5a3cd89
Show file tree
Hide file tree
Showing 9 changed files with 687 additions and 138 deletions.
4 changes: 3 additions & 1 deletion build.rs
@@ -1,2 +1,4 @@
// Empty `build.rs` so that `[package] links = ...` works in `Cargo.toml`.
fn main() {}
fn main() {
println!("cargo:rerun-if-changed=build.rs");
}
7 changes: 0 additions & 7 deletions crates/cli-support/src/descriptor.rs
Expand Up @@ -189,13 +189,6 @@ impl Descriptor {
}
}

pub fn ref_closure(&self) -> Option<&Closure> {
match *self {
Descriptor::Ref(ref s) => s.closure(),
_ => None,
}
}

pub fn closure(&self) -> Option<&Closure> {
match *self {
Descriptor::Closure(ref s) => Some(s),
Expand Down

0 comments on commit 5a3cd89

Please sign in to comment.