File tree Expand file tree Collapse file tree 3 files changed +12
-17
lines changed Expand file tree Collapse file tree 3 files changed +12
-17
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ $ cargo add wstd
81
81
```
82
82
83
83
## Safety
84
- This crate uses `` #![deny (unsafe_code)] `` to ensure everything is implemented in
84
+ This crate uses `` #![forbid (unsafe_code)] `` to ensure everything is implemented in
85
85
100% Safe Rust.
86
86
87
87
## Contributing
Original file line number Diff line number Diff line change 1
1
#![ allow( async_fn_in_trait) ]
2
2
#![ warn( future_incompatible, unreachable_pub) ]
3
+ #![ forbid( unsafe_code) ]
3
4
//#![deny(missing_debug_implementations)]
4
5
//#![warn(missing_docs)]
5
6
//#![forbid(rustdoc::missing_doc_code_examples)]
Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ use super::{Reactor, REACTOR};
2
2
3
3
use core:: future:: Future ;
4
4
use core:: pin:: pin;
5
- use core:: ptr;
6
5
use core:: task:: Waker ;
7
- use core:: task:: { Context , Poll , RawWaker , RawWakerVTable } ;
6
+ use core:: task:: { Context , Poll } ;
7
+ use std:: sync:: Arc ;
8
+ use std:: task:: Wake ;
8
9
9
10
/// Start the event loop
10
11
pub fn block_on < Fut > ( fut : Fut ) -> Fut :: Output
@@ -42,18 +43,11 @@ where
42
43
/// Construct a new no-op waker
43
44
// NOTE: we can remove this once <https://github.com/rust-lang/rust/issues/98286> lands
44
45
fn noop_waker ( ) -> Waker {
45
- const VTABLE : RawWakerVTable = RawWakerVTable :: new (
46
- // Cloning just returns a new no-op raw waker
47
- |_| RAW ,
48
- // `wake` does nothing
49
- |_| { } ,
50
- // `wake_by_ref` does nothing
51
- |_| { } ,
52
- // Dropping does nothing as we don't allocate anything
53
- |_| { } ,
54
- ) ;
55
- const RAW : RawWaker = RawWaker :: new ( ptr:: null ( ) , & VTABLE ) ;
56
-
57
- // SAFETY: all fields are no-ops, so this is safe
58
- unsafe { Waker :: from_raw ( RAW ) }
46
+ struct NoopWaker ;
47
+
48
+ impl Wake for NoopWaker {
49
+ fn wake ( self : Arc < Self > ) { }
50
+ }
51
+
52
+ Waker :: from ( Arc :: new ( NoopWaker ) )
59
53
}
You can’t perform that action at this time.
0 commit comments