Expand description
§min-specialization

Rust’s specialization feature allows you to provide a default implementation of a trait for generic types and then specialize it for specific types. This feature is currently unstable and only available on the nightly version of Rust.
This crate emulates Rust’s #[feature(min_specialization)]
unstable feature on stable Rust.
§Example
#[specialization]
mod inner {
#[allow(unused)]
trait Trait<U> {
type Ty;
fn number(_: U) -> Self::Ty;
}
impl<T, U> Trait<U> for T {
type Ty = usize;
default fn number(_: U) -> Self::Ty {
0
}
}
impl<U> Trait<U> for () {
fn number(_: U) -> Self::Ty {
1
}
}
}
see tests
for more.