Skip to main content

compio_runtime/
lib.rs

1//! The compio runtime.
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#![cfg_attr(feature = "future-combinator", feature(context_ext, local_waker))]
14#![warn(missing_docs)]
15#![deny(rustdoc::broken_intra_doc_links)]
16#![doc(
17    html_logo_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
18)]
19#![doc(
20    html_favicon_url = "https://github.com/compio-rs/compio-logo/raw/refs/heads/master/generated/colored-bold.svg"
21)]
22
23mod affinity;
24mod attacher;
25mod runtime;
26
27#[cfg(feature = "event")]
28pub mod event;
29#[cfg(feature = "future-combinator")]
30pub mod future;
31#[cfg(feature = "time")]
32pub mod time;
33
34pub use async_task::Task;
35pub use attacher::*;
36use compio_buf::BufResult;
37#[allow(hidden_glob_reexports, unused)]
38use runtime::RuntimeInner; // used to shadow glob export so that RuntimeInner is not exported
39pub use runtime::*;
40/// Macro that asserts a type *DOES NOT* implement some trait. Shamelessly
41/// copied from <https://users.rust-lang.org/t/a-macro-to-assert-that-a-type-does-not-implement-trait-bounds/31179>.
42///
43/// # Example
44///
45/// ```rust,ignore
46/// assert_not_impl!(u8, From<u16>);
47/// ```
48macro_rules! assert_not_impl {
49    ($x:ty, $($t:path),+ $(,)*) => {
50        const _: fn() -> () = || {
51            struct Check<T: ?Sized>(T);
52            trait AmbiguousIfImpl<A> { fn some_item() { } }
53
54            impl<T: ?Sized> AmbiguousIfImpl<()> for Check<T> { }
55            impl<T: ?Sized $(+ $t)*> AmbiguousIfImpl<u8> for Check<T> { }
56
57            <Check::<$x> as AmbiguousIfImpl<_>>::some_item()
58        };
59    };
60}
61
62use assert_not_impl;