I have a simple specialization use case that I want to translate to any existing mechanism we have in stable Rust to do specialization:
pub trait IsU8 {
type Status: Boolean;
}
pub trait Boolean {}
pub struct True;
pub struct False;
impl Boolean for True {}
impl Boolean for False {}
impl<T> IsU8 for u8 {
type Status = True;
}
default impl<T> IsU8 for T {
type Status = False;
}
More specifically:
- I have an
IsU8
trait. - I want the implementation of this trait for
u8
to haveStatus
beTrue
. - I want the implementation of this trait for all other types to have
Status
beFalse
.
Are there any techniques in stable Rust to achieve the above?