Skip to content

Commit 7a511a3

Browse files
committed
Derive Debug impls
1 parent 21a6803 commit 7a511a3

File tree

6 files changed

+10
-47
lines changed

6 files changed

+10
-47
lines changed

crates/console-timer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ features = [
1111
]
1212

1313
[dev-dependencies]
14-
wasm-bindgen-test = "0.2.40"
14+
wasm-bindgen-test = "0.2.41"
1515
gloo-timers = { version = "0.1.0", path = "../timers" }

crates/events/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Rust and WebAssembly Working Group"]
55
edition = "2018"
66

77
[dependencies]
8-
wasm-bindgen = "0.2.37"
8+
wasm-bindgen = "0.2.41"
99

1010
[dependencies.web-sys]
1111
version = "0.3.14"
@@ -18,7 +18,7 @@ features = [
1818
[dev-dependencies]
1919
js-sys = "0.3.14"
2020
futures = "0.1.25"
21-
wasm-bindgen-test = "0.2.37"
21+
wasm-bindgen-test = "0.2.41"
2222

2323
[dev-dependencies.web-sys]
2424
version = "0.3.14"

crates/events/src/lib.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ thread_local! {
225225
/// }
226226
/// }
227227
/// ```
228+
#[derive(Debug)]
228229
#[must_use = "event listener will never be called after being dropped"]
229230
pub struct EventListener {
230231
target: EventTarget,
@@ -580,15 +581,3 @@ impl Drop for EventListener {
580581
}
581582
}
582583
}
583-
584-
// TODO Remove this after https://github.com/rustwasm/wasm-bindgen/issues/1387 is fixed
585-
impl std::fmt::Debug for EventListener {
586-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
587-
f.debug_struct("EventListener")
588-
.field("target", &self.target)
589-
.field("event_type", &self.event_type)
590-
.field("callback", &"Closure { ... }")
591-
.field("phase", &self.phase)
592-
.finish()
593-
}
594-
}

crates/timers/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Rust and WebAssembly Working Group"]
55
edition = "2018"
66

77
[dependencies]
8-
wasm-bindgen = "0.2.40"
8+
wasm-bindgen = "0.2.41"
99
js-sys = "0.3.17"
1010

1111
[dependencies.futures_rs]
@@ -29,4 +29,4 @@ futures = ["futures_rs", "wasm-bindgen-futures"]
2929

3030

3131
[dev-dependencies]
32-
wasm-bindgen-test = "0.2.40"
32+
wasm-bindgen-test = "0.2.41"

crates/timers/src/callback.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Callback-style timer APIs.
22
33
use super::sys::*;
4-
use std::fmt;
54
use wasm_bindgen::prelude::*;
65
use wasm_bindgen::JsCast;
76

@@ -11,6 +10,7 @@ use wasm_bindgen::JsCast;
1110
///
1211
/// Once scheduled, you can either `cancel` so that it doesn't run or `forget`
1312
/// it so that it is un-cancel-able.
13+
#[derive(Debug)]
1414
#[must_use = "timeouts cancel on drop; either call `forget` or `drop` explicitly"]
1515
pub struct Timeout {
1616
id: Option<i32>,
@@ -25,12 +25,6 @@ impl Drop for Timeout {
2525
}
2626
}
2727

28-
impl fmt::Debug for Timeout {
29-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30-
f.debug_struct("Timeout").field("id", &self.id).finish()
31-
}
32-
}
33-
3428
impl Timeout {
3529
/// Schedule a timeout to invoke `callback` in `millis` milliseconds from
3630
/// now.
@@ -114,6 +108,7 @@ impl Timeout {
114108
///
115109
/// Once scheduled, you can either `cancel` so that it ceases to fire or `forget`
116110
/// it so that it is un-cancel-able.
111+
#[derive(Debug)]
117112
#[must_use = "intervals cancel on drop; either call `forget` or `drop` explicitly"]
118113
pub struct Interval {
119114
id: Option<i32>,
@@ -128,12 +123,6 @@ impl Drop for Interval {
128123
}
129124
}
130125

131-
impl fmt::Debug for Interval {
132-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
133-
f.debug_struct("Interval").field("id", &self.id).finish()
134-
}
135-
}
136-
137126
impl Interval {
138127
/// Schedule an interval to invoke `callback` every `millis` milliseconds.
139128
///

crates/timers/src/future.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use super::sys::*;
44
use futures::prelude::*;
55
use futures::sync::mpsc;
6-
use std::fmt;
76
use wasm_bindgen::prelude::*;
87
use wasm_bindgen::JsCast;
98
use wasm_bindgen_futures::JsFuture;
@@ -47,6 +46,7 @@ use wasm_bindgen_futures::JsFuture;
4746
/// })
4847
/// );
4948
/// ```
49+
#[derive(Debug)]
5050
#[must_use = "futures do nothing unless polled or spawned"]
5151
pub struct TimeoutFuture {
5252
id: Option<i32>,
@@ -92,14 +92,6 @@ impl TimeoutFuture {
9292
}
9393
}
9494

95-
impl fmt::Debug for TimeoutFuture {
96-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
97-
f.debug_struct("TimeoutFuture")
98-
.field("id", &self.id)
99-
.finish()
100-
}
101-
}
102-
10395
impl Future for TimeoutFuture {
10496
type Item = ();
10597
type Error = ();
@@ -121,6 +113,7 @@ impl Future for TimeoutFuture {
121113
/// you can `drop` the stream.
122114
///
123115
/// An interval stream will never resolve to `Err`.
116+
#[derive(Debug)]
124117
#[must_use = "streams do nothing unless polled or spawned"]
125118
pub struct IntervalStream {
126119
millis: u32,
@@ -174,14 +167,6 @@ impl Drop for IntervalStream {
174167
}
175168
}
176169

177-
impl fmt::Debug for IntervalStream {
178-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
179-
f.debug_struct("IntervalStream")
180-
.field("id", &self.id)
181-
.finish()
182-
}
183-
}
184-
185170
impl Stream for IntervalStream {
186171
type Item = ();
187172
type Error = ();

0 commit comments

Comments
 (0)