Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(associated_consts)]
- trait Foo {
- type X: 'static;
- const ID: &'static [Self::X];
- }
- impl Foo for i32 {
- type X = i32;
- const ID: &'static [i32] = &[5];
- }
- impl Foo for i64 {
- type X = i32;
- const ID: &'static [i32] = &[6];
- }
- fn main() {
- assert_eq!(5, i32::ID[0]);
- assert_eq!(6, i64::ID[1]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement