pub trait RuntimeMarker: private::Sealed {}
impl RuntimeMarker for () {}
pub trait FnMarker: private::Sealed {}
pub trait FnMarkerAggr<Other: FnMarker>: FnMarker {
type Output: FnMarker;
}
pub trait FnResult<'a, T>: FnMarker {
type Output;
}
impl FnMarker for () {}
impl FnMarkerAggr<()> for () {
type Output = ();
}
impl<'a, T> FnResult<'a, T> for () {
type Output = T;
}
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub use async_marker::*;
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
mod async_marker {
use super::{FnMarker, FnMarkerAggr, FnResult, RuntimeMarker};
use crate::r#async::Runtime;
impl<T: Runtime> RuntimeMarker for T {}
pub trait FnMarkerAsync: FnMarker {}
#[allow(missing_debug_implementations)]
pub enum Async {}
impl FnMarker for Async {}
impl FnMarkerAsync for Async {}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
impl FnMarkerAggr<()> for Async {
type Output = Async;
}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
impl FnMarkerAggr<Async> for () {
type Output = Async;
}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
impl FnMarkerAggr<Async> for Async {
type Output = Async;
}
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
impl<'a, T> FnResult<'a, T> for Async {
type Output = futures::future::BoxFuture<'a, T>;
}
}
mod private {
#![allow(unused)]
use super::*;
#[cfg(feature = "async")]
use crate::r#async::Runtime;
pub trait Sealed: 'static {}
impl Sealed for () {}
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
impl Sealed for Async {}
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
impl<T: Runtime> Sealed for T {}
}
#[cfg(test)]
mod test {
#![allow(unused)]
#![allow(clippy::let_unit_value)]
use super::*;
fn test_fn_marker_aggregation<M1, M2>() -> <M1 as FnMarkerAggr<M2>>::Output
where
M1: FnMarker + FnMarkerAggr<M2>,
M2: FnMarker,
{
todo!()
}
fn test_eval_result<'a, M, T>() -> <M as FnResult<'a, T>>::Output
where
M: FnResult<'a, T> + FnMarker,
{
todo!()
}
fn t1() {
let x = test_fn_marker_aggregation::<(), ()>();
let v = test_eval_result::<(), i32>();
#[cfg(feature = "async")]
{
use crate::marker::Async;
let x = test_fn_marker_aggregation::<(), Async>();
let x = test_fn_marker_aggregation::<Async, ()>();
let x = test_fn_marker_aggregation::<Async, Async>();
let v = test_eval_result::<Async, i32>();
}
}
}