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    BorrowedBuffer, BufferPool, JoinHandle, Runtime, RuntimeBuilder, spawn, spawn_blocking, submit,
29    submit_with_flags,
30};
31
32/// Macro that asserts a type *DOES NOT* implement some trait. Shamelessly
33/// copied from <https://users.rust-lang.org/t/a-macro-to-assert-that-a-type-does-not-implement-trait-bounds/31179>.
34///
35/// # Example
36///
37/// ```rust,ignore
38/// assert_not_impl!(u8, From<u16>);
39/// ```
40macro_rules! assert_not_impl {
41    ($x:ty, $($t:path),+ $(,)*) => {
42        const _: fn() -> () = || {
43            struct Check<T: ?Sized>(T);
44            trait AmbiguousIfImpl<A> { fn some_item() { } }
45
46            impl<T: ?Sized> AmbiguousIfImpl<()> for Check<T> { }
47            impl<T: ?Sized $(+ $t)*> AmbiguousIfImpl<u8> for Check<T> { }
48
49            <Check::<$x> as AmbiguousIfImpl<_>>::some_item()
50        };
51    };
52}
53
54use assert_not_impl;