Skip to content

Commit 5a3cd89

Browse files
committed
Implement AsRef<JsValue> for Closure<T>
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>`.
1 parent cda7175 commit 5a3cd89

File tree

9 files changed

+687
-138
lines changed

9 files changed

+687
-138
lines changed

build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
// Empty `build.rs` so that `[package] links = ...` works in `Cargo.toml`.
2-
fn main() {}
2+
fn main() {
3+
println!("cargo:rerun-if-changed=build.rs");
4+
}

crates/cli-support/src/descriptor.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,6 @@ impl Descriptor {
189189
}
190190
}
191191

192-
pub fn ref_closure(&self) -> Option<&Closure> {
193-
match *self {
194-
Descriptor::Ref(ref s) => s.closure(),
195-
_ => None,
196-
}
197-
}
198-
199192
pub fn closure(&self) -> Option<&Closure> {
200193
match *self {
201194
Descriptor::Closure(ref s) => Some(s),

0 commit comments

Comments
 (0)