Created
May 7, 2016 20:58
Shared via Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(specialization)] | |
pub trait NotSame {} | |
pub struct True; | |
pub struct False; | |
pub trait Sameness { | |
type Same; | |
} | |
mod internal { | |
pub trait PrivSameness { | |
type Same; | |
} | |
} | |
use internal::PrivSameness; | |
impl<A, B> Sameness for (A, B) { | |
type Same = <Self as PrivSameness>::Same; | |
} | |
impl<A, B> PrivSameness for (A, B) { | |
default type Same = False; | |
} | |
impl<A> PrivSameness for (A, A) { | |
type Same = True; | |
} | |
impl<A, B> NotSame for (A, B) where (A, B): Sameness<Same=False> {} | |
fn not_same<A, B>() where (A, B): NotSame {} | |
fn main() { | |
not_same::<i32, f32>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment