mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
Implement Debug for JsFuture
This commit is contained in:
parent
7decb133f0
commit
04a78badc5
@ -104,6 +104,7 @@
|
|||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
use std::fmt;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@ -128,6 +129,12 @@ pub struct JsFuture {
|
|||||||
callbacks: Option<(Closure<FnMut(JsValue)>, Closure<FnMut(JsValue)>)>,
|
callbacks: Option<(Closure<FnMut(JsValue)>, Closure<FnMut(JsValue)>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for JsFuture {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "JsFuture {{ ... }}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<Promise> for JsFuture {
|
impl From<Promise> for JsFuture {
|
||||||
fn from(js: Promise) -> JsFuture {
|
fn from(js: Promise) -> JsFuture {
|
||||||
// Use the `then` method to schedule two callbacks, one for the
|
// Use the `then` method to schedule two callbacks, one for the
|
||||||
|
@ -52,6 +52,13 @@ fn error_future_is_rejected_promise() -> impl Future<Item = (), Error = JsValue>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn debug_jsfuture() {
|
||||||
|
let p = js_sys::Promise::resolve(&JsValue::from(42));
|
||||||
|
let f = JsFuture::from(p);
|
||||||
|
assert_eq!(&format!("{:?}", f), "JsFuture { ... }");
|
||||||
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn setTimeout(c: &Closure<FnMut()>);
|
fn setTimeout(c: &Closure<FnMut()>);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user