#[specialize]Expand description
#[specialize] attribute macro for distributed specialization across files.
Mark individual items as default with #[specialize(default)].
Supports multi-generic constraints.
§Usage
ⓘ
trait MyTrait {
type Output;
fn describe(&self) -> Self::Output;
}
// Most general (default) implementation
#[specialize(default)]
impl<T> MyTrait for T {
type Output = ();
fn describe(&self) -> Self::Output { () }
}
// More specific - with constraint
#[specialize(T: Clone)]
impl<T> MyTrait for T {
type Output = T;
fn describe(&self) -> Self::Output { self.clone() }
}
// Multiple generics
#[specialize(T: Clone, U: Copy)]
impl<T, U> Pair<T, U> for (T, U) { ... }
// Most specific - concrete type
#[specialize]
impl MyTrait for String {
fn describe(&self) -> Self::Output { self.clone() }
}