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:
You can also implement unsafe
traits
Add attributes to all impls:
ⓘ
marker_impls! {
#[allow(lint)]
#[unstable(feature = "marker_trait", issue = "none")]
MarkerTrait for u8, i8
}
And use generics:
ⓘ
marker_impls! {
MarkerTrait for
u8, i8,
{T: ?Sized} *const T,
{T: ?Sized} *mut T,
{T: MarkerTrait} PhantomData<T>,
u32,
}