File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 4
4
//! closures" from Rust to JS. Some more details can be found on the `Closure`
5
5
//! type itself.
6
6
7
+ use std:: fmt;
7
8
#[ cfg( feature = "nightly" ) ]
8
9
use std:: marker:: Unsize ;
9
10
use std:: mem:: { self , ManuallyDrop } ;
@@ -489,6 +490,15 @@ fn _check() {
489
490
_assert :: < & Closure < FnMut ( ) -> String > > ( ) ;
490
491
}
491
492
493
+ impl < T > fmt:: Debug for Closure < T >
494
+ where
495
+ T : ?Sized ,
496
+ {
497
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
498
+ write ! ( f, "Closure {{ ... }}" )
499
+ }
500
+ }
501
+
492
502
impl < T > Drop for Closure < T >
493
503
where
494
504
T : ?Sized ,
Original file line number Diff line number Diff line change @@ -107,6 +107,12 @@ fn cannot_reuse() {
107
107
assert ! ( cannot_reuse_call_again( ) . is_err( ) ) ;
108
108
}
109
109
110
+ #[ wasm_bindgen_test]
111
+ fn debug ( ) {
112
+ let closure = Closure :: wrap ( Box :: new ( || { } ) as Box < FnMut ( ) > ) ;
113
+ assert_eq ! ( & format!( "{:?}" , closure) , "Closure { ... }" ) ;
114
+ }
115
+
110
116
#[ wasm_bindgen_test]
111
117
fn long_lived ( ) {
112
118
let hit = Rc :: new ( Cell :: new ( false ) ) ;
You can’t perform that action at this time.
0 commit comments