Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! The ntest lib enhances the rust test framework with some useful functions.
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::mpscrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/;
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/;
4 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#;
5
6 #[doc(hidden)]
7 /// Timeout helper for proc macro timeout
8 pub fn execute_with_timeoutrust-analyzer cargo ntest_proc_macro_helper 0.8.0 execute_with_timeout().<T: Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send#>(
9 code: &'static (dyn Fnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/Fn#() -> T + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static),
10 timeout_ms: u64,
11 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> {
12 let (sender, receiver) = mpscrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/::channelrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/channel().();
13 threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::spawnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/spawn().(move || {
14 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) = sender.sendrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/impl#[`Sender<T>`]send().(code()) {}
15 });
16 match receiver.recv_timeoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/impl#[`Receiver<T>`]recv_timeout().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(timeout_ms)) {
17 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(t),
18 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
19 }
20 }