-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
good first issueThis is a good issue for people who have never contributed to wasm-bindgen beforeThis is a good issue for people who have never contributed to wasm-bindgen before
Description
Motivation
When implementing rustwasm/gloo#30, I created this type:
pub struct EventListener<'a> {
target: EventTarget,
kind: &'a str,
callback: Option<Closure<FnMut(Event)>>,
}
I would really like to just slap a #[derive(Debug)]
and call it a day, but Closure
doesn't impl Debug
, so I have to do this instead:
impl<'a> std::fmt::Debug for EventListener<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("EventListener")
.field("target", &self.target)
.field("kind", &self.kind)
.field("callback", &"Closure { ... }")
.finish()
}
}
Proposed Solution
I propose that Closure
should provide a Debug
impl, which essentially just outputs Closure { ... }
(or similar).
Alternatives
Maybe the Debug
impl should expose more information? For example, it could call .toString()
on the JS function.
chinedufn, fitzgen and samcday
Metadata
Metadata
Assignees
Labels
good first issueThis is a good issue for people who have never contributed to wasm-bindgen beforeThis is a good issue for people who have never contributed to wasm-bindgen before