File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ $ cargo add wstd
8181```
8282
8383## 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
8585100% Safe Rust.
8686
8787## Contributing
Original file line number Diff line number Diff line change 11#![ allow( async_fn_in_trait) ]
22#![ warn( future_incompatible, unreachable_pub) ]
3+ #![ forbid( unsafe_code) ]
34//#![deny(missing_debug_implementations)]
45//#![warn(missing_docs)]
56//#![forbid(rustdoc::missing_doc_code_examples)]
Original file line number Diff line number Diff line change @@ -2,9 +2,10 @@ use super::{Reactor, REACTOR};
22
33use core:: future:: Future ;
44use core:: pin:: pin;
5- use core:: ptr;
65use 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 ;
89
910/// Start the event loop
1011pub fn block_on < Fut > ( fut : Fut ) -> Fut :: Output
@@ -42,18 +43,11 @@ where
4243/// Construct a new no-op waker
4344// NOTE: we can remove this once <https://github.com/rust-lang/rust/issues/98286> lands
4445fn 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 ) )
5953}
You can’t perform that action at this time.
0 commit comments