compio_runtime/
lib.rs

1//! The runtime of compio.
2//!
3//! ```
4//! let ans = compio_runtime::Runtime::new().unwrap().block_on(async {
5//!     println!("Hello world!");
6//!     42
7//! });
8//! assert_eq!(ans, 42);
9//! ```
10
11#![cfg_attr(docsrs, feature(doc_cfg))]
12#![cfg_attr(feature = "current_thread_id", feature(current_thread_id))]
13#![warn(missing_docs)]
14
15mod affinity;
16mod attacher;
17mod runtime;
18
19#[cfg(feature = "event")]
20pub mod event;
21#[cfg(feature = "time")]
22pub mod time;
23
24pub use async_task::Task;
25pub use attacher::*;
26use compio_buf::BufResult;
27pub use runtime::*;
28
29/// Macro that asserts a type *DOES NOT* implement some trait. Shamelessly
30/// copied from <https://users.rust-lang.org/t/a-macro-to-assert-that-a-type-does-not-implement-trait-bounds/31179>.
31///
32/// # Example
33///
34/// ```rust,ignore
35/// assert_not_impl!(u8, From<u16>);
36/// ```
37macro_rules! assert_not_impl {
38    ($x:ty, $($t:path),+ $(,)*) => {
39        const _: fn() -> () = || {
40            struct Check<T: ?Sized>(T);
41            trait AmbiguousIfImpl<A> { fn some_item() { } }
42
43            impl<T: ?Sized> AmbiguousIfImpl<()> for Check<T> { }
44            impl<T: ?Sized $(+ $t)*> AmbiguousIfImpl<u8> for Check<T> { }
45
46            <Check::<$x> as AmbiguousIfImpl<_>>::some_item()
47        };
48    };
49}
50
51use assert_not_impl;