Debian Codegraph @

examples/high_precision.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#};
2
3 use callooprust-analyzer cargo calloop 0.10.5 crate/::{
4 timerrust-analyzer cargo calloop 0.10.5 sources/timer/::{TimeoutActionrust-analyzer cargo calloop 0.10.5 sources/timer/TimeoutAction#, Timerrust-analyzer cargo calloop 0.10.5 sources/timer/Timer#},
5 EventLooprust-analyzer cargo calloop 0.10.5 loop_logic/EventLoop#,
6 };
7
8 fn mainrust-analyzer cargo calloop 0.10.5 main().() {
9 let mut event_loop =
10 EventLooprust-analyzer cargo calloop 0.10.5 loop_logic/EventLoop#::try_new_high_precisionrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]try_new_high_precision().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to initialize the event loop!");
11
12 let before = Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().();
13
14 event_loop
15 .handlerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]handle().()
16 .insert_sourcerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]insert_source().(
17 Timerrust-analyzer cargo calloop 0.10.5 sources/timer/Timer#::from_durationrust-analyzer cargo calloop 0.10.5 sources/timer/impl#[Timer]from_duration().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_microsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_micros().(20)),
18 |_, _, _| TimeoutActionrust-analyzer cargo calloop 0.10.5 sources/timer/TimeoutAction#::Droprust-analyzer cargo calloop 0.10.5 sources/timer/TimeoutAction#Drop#,
19 )
20 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
21
22 event_loop.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &mut ()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
23
24 let elapsed = before.elapsedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]elapsed().();
25
26 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!(
27 "The event loop slept for {} microseconds.",
28 elapsed.as_microsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]as_micros().()
29 );
30 }