1 个稳定版本
1.0.0 | 2023年9月18日 |
---|
#1618 在 Rust 模式
12KB
159 行
为标记特质实现全量实现。
基本示例
#[marker_trait::marker_trait]
pub trait AsyncTask: Send + 'static {}
struct MySendStatic;
static_assertions::assert_impl_all!(MySendStatic: Send, AsyncTask);
生成输出
pub trait AsyncTask: Send + 'static {}
impl<T: Send + 'static> AsyncTask for T {}
密封示例
#[marker_trait::marker_trait(sealed)]
pub trait AsyncTask: Send + 'static {}
struct MySendStatic;
static_assertions::assert_impl_all!(MySendStatic: Send, AsyncTask, __SealModuleForAsyncTask__::Sealed);
生成输出
pub trait AsyncTask: Send + 'static + __SealModuleForAsyncTask__::Sealed {}
mod __SealModuleForAsyncTask__ {
use super::*;
impl<__AsyncTaskImplementor__> Sealed for __AsyncTaskImplementor__
where __AsyncTaskImplementor__: Send + 'static {}
pub trait Sealed {}
}
#[automatically_derived]
impl<__MarkerTrait__: Send + 'static + __SealModuleForAsyncTask__::Sealed> AsyncTask for __MarkerTrait__ {}
依赖项
~0.4–0.8MB
~19K SLoC