-
-
Save rust-play/2c4ea6be32627b25a23ec526551219ce to your computer and use it in GitHub Desktop.
Code shared from the 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(const_generics)] | |
#![feature(const_evaluatable_checked)] | |
#![feature(const_fn)] | |
trait MiniTypeId { | |
const TYPE_ID: u64; | |
} | |
impl<T> MiniTypeId for T { | |
const TYPE_ID: u64 = 0; | |
} | |
enum Lift<const V: bool> {} | |
trait IsFalse {} | |
impl IsFalse for Lift<false> {} | |
const fn is_same_type<T: MiniTypeId, U: MiniTypeId>() -> bool { | |
T::TYPE_ID == U::TYPE_ID | |
} | |
fn requires_distinct<A, B>(_a: A, _b: B) where | |
A: MiniTypeId, B: MiniTypeId, | |
Lift<{is_same_type::<A, B>()}>: IsFalse {} | |
fn main() { | |
requires_distinct("str", 12); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment