mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-15 04:23:12 +03:00
parent
30b258515d
commit
1914bba0be
@ -4,6 +4,7 @@
|
||||
//! closures" from Rust to JS. Some more details can be found on the `Closure`
|
||||
//! type itself.
|
||||
|
||||
use std::fmt;
|
||||
#[cfg(feature = "nightly")]
|
||||
use std::marker::Unsize;
|
||||
use std::mem::{self, ManuallyDrop};
|
||||
@ -489,6 +490,15 @@ fn _check() {
|
||||
_assert::<&Closure<FnMut() -> String>>();
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Closure<T>
|
||||
where
|
||||
T: ?Sized,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "Closure {{ ... }}")
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for Closure<T>
|
||||
where
|
||||
T: ?Sized,
|
||||
|
@ -107,6 +107,12 @@ fn cannot_reuse() {
|
||||
assert!(cannot_reuse_call_again().is_err());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn debug() {
|
||||
let closure = Closure::wrap(Box::new(|| {}) as Box<FnMut()>);
|
||||
assert_eq!(&format!("{:?}", closure), "Closure { ... }");
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn long_lived() {
|
||||
let hit = Rc::new(Cell::new(false));
|
||||
|
Loading…
Reference in New Issue
Block a user