2020-06-20 04:48:42 -05:00
|
|
|
#![allow(incomplete_features)]
|
2016-06-20 05:33:54 -05:00
|
|
|
#![feature(specialization)]
|
|
|
|
|
2016-03-28 18:59:48 -05:00
|
|
|
trait IsUnit {
|
|
|
|
fn is_unit() -> bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> IsUnit for T {
|
2022-06-20 18:00:37 -05:00
|
|
|
default fn is_unit() -> bool {
|
|
|
|
false
|
|
|
|
}
|
2016-03-28 18:59:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl IsUnit for () {
|
2022-06-20 18:00:37 -05:00
|
|
|
fn is_unit() -> bool {
|
|
|
|
true
|
|
|
|
}
|
2016-03-28 18:59:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn specialization() -> (bool, bool) {
|
|
|
|
(i32::is_unit(), <()>::is_unit())
|
|
|
|
}
|
2016-04-22 03:34:14 -05:00
|
|
|
|
2016-04-22 07:38:46 -05:00
|
|
|
fn main() {
|
|
|
|
assert_eq!(specialization(), (false, true));
|
|
|
|
}
|