Skip to content

Derive Debug impls #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/console-timer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ features = [
]

[dev-dependencies]
wasm-bindgen-test = "0.2.40"
wasm-bindgen-test = "0.2.43"
gloo-timers = { version = "0.1.0", path = "../timers" }
5 changes: 3 additions & 2 deletions crates/events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Rust and WebAssembly Working Group"]
edition = "2018"

[dependencies]
wasm-bindgen = "0.2.37"
wasm-bindgen = "0.2.43"

[dependencies.web-sys]
version = "0.3.14"
Expand All @@ -18,9 +18,10 @@ features = [
[dev-dependencies]
js-sys = "0.3.14"
futures = "0.1.25"
wasm-bindgen-test = "0.2.37"
wasm-bindgen-test = "0.2.43"

[dev-dependencies.web-sys]
version = "0.3.14"
features = [
"HtmlElement",
"Window",
Expand Down
13 changes: 1 addition & 12 deletions crates/events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ thread_local! {
/// }
/// }
/// ```
#[derive(Debug)]
#[must_use = "event listener will never be called after being dropped"]
pub struct EventListener {
target: EventTarget,
Expand Down Expand Up @@ -580,15 +581,3 @@ impl Drop for EventListener {
}
}
}

// TODO Remove this after https://github.com/rustwasm/wasm-bindgen/issues/1387 is fixed
impl std::fmt::Debug for EventListener {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("EventListener")
.field("target", &self.target)
.field("event_type", &self.event_type)
.field("callback", &"Closure { ... }")
.field("phase", &self.phase)
.finish()
}
}
8 changes: 4 additions & 4 deletions crates/timers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Rust and WebAssembly Working Group"]
edition = "2018"

[dependencies]
wasm-bindgen = "0.2.40"
wasm-bindgen = "0.2.43"
js-sys = "0.3.17"

[dependencies.futures_rs]
Expand All @@ -14,11 +14,11 @@ version = "0.1.25"
optional = true

[dependencies.wasm-bindgen-futures]
version = "0.3.17"
version = "0.3.19"
optional = true

[dependencies.web-sys]
version = "0.3.17"
version = "0.3.19"
features = [
"Window",
]
Expand All @@ -29,4 +29,4 @@ futures = ["futures_rs", "wasm-bindgen-futures"]


[dev-dependencies]
wasm-bindgen-test = "0.2.40"
wasm-bindgen-test = "0.2.43"
15 changes: 2 additions & 13 deletions crates/timers/src/callback.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Callback-style timer APIs.

use super::sys::*;
use std::fmt;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;

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

impl fmt::Debug for Timeout {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Timeout").field("id", &self.id).finish()
}
}

impl Timeout {
/// Schedule a timeout to invoke `callback` in `millis` milliseconds from
/// now.
Expand Down Expand Up @@ -114,6 +108,7 @@ impl Timeout {
///
/// Once scheduled, you can either `cancel` so that it ceases to fire or `forget`
/// it so that it is un-cancel-able.
#[derive(Debug)]
#[must_use = "intervals cancel on drop; either call `forget` or `drop` explicitly"]
pub struct Interval {
id: Option<i32>,
Expand All @@ -128,12 +123,6 @@ impl Drop for Interval {
}
}

impl fmt::Debug for Interval {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("Interval").field("id", &self.id).finish()
}
}

impl Interval {
/// Schedule an interval to invoke `callback` every `millis` milliseconds.
///
Expand Down
19 changes: 2 additions & 17 deletions crates/timers/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use super::sys::*;
use futures::prelude::*;
use futures::sync::mpsc;
use std::fmt;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
Expand Down Expand Up @@ -47,6 +46,7 @@ use wasm_bindgen_futures::JsFuture;
/// })
/// );
/// ```
#[derive(Debug)]
#[must_use = "futures do nothing unless polled or spawned"]
pub struct TimeoutFuture {
id: Option<i32>,
Expand Down Expand Up @@ -92,14 +92,6 @@ impl TimeoutFuture {
}
}

impl fmt::Debug for TimeoutFuture {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("TimeoutFuture")
.field("id", &self.id)
.finish()
}
}

impl Future for TimeoutFuture {
type Item = ();
type Error = ();
Expand All @@ -121,6 +113,7 @@ impl Future for TimeoutFuture {
/// you can `drop` the stream.
///
/// An interval stream will never resolve to `Err`.
#[derive(Debug)]
#[must_use = "streams do nothing unless polled or spawned"]
pub struct IntervalStream {
millis: u32,
Expand Down Expand Up @@ -174,14 +167,6 @@ impl Drop for IntervalStream {
}
}

impl fmt::Debug for IntervalStream {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("IntervalStream")
.field("id", &self.id)
.finish()
}
}

impl Stream for IntervalStream {
type Item = ();
type Error = ();
Expand Down