Macro core::marker::marker_impls

source ·
macro marker_impls {
    ( $(#[$($meta:tt)*])* $Trait:ident for $({$($bounds:tt)*})? $T:ty $(, $($rest:tt)*)? ) => { ... },
    ( $(#[$($meta:tt)*])* $Trait:ident for ) => { ... },
    ( $(#[$($meta:tt)*])* unsafe $Trait:ident for $({$($bounds:tt)*})? $T:ty $(, $($rest:tt)*)? ) => { ... },
    ( $(#[$($meta:tt)*])* unsafe $Trait:ident for ) => { ... },
}
🔬This is a nightly-only experimental API. (internal_impls_macro)
Expand description

Implements a given marker trait for multiple types at the same time.

The basic syntax looks like this:

marker_impls! { MarkerTrait for u8, i8 }
Run

You can also implement unsafe traits

marker_impls! { unsafe MarkerTrait for u8, i8 }
Run

Add attributes to all impls:

marker_impls! {
    #[allow(lint)]
    #[unstable(feature = "marker_trait", issue = "none")]
    MarkerTrait for u8, i8
}
Run

And use generics:

marker_impls! {
    MarkerTrait for
        u8, i8,
        {T: ?Sized} *const T,
        {T: ?Sized} *mut T,
        {T: MarkerTrait} PhantomData<T>,
        u32,
}
Run