Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #![feature(associated_consts)]
  2.  
  3. trait Foo {
  4. type X: 'static;
  5. const ID: &'static [Self::X];
  6. }
  7.  
  8. impl Foo for i32 {
  9. type X = i32;
  10. const ID: &'static [i32] = &[5];
  11. }
  12.  
  13. impl Foo for i64 {
  14. type X = i32;
  15. const ID: &'static [i32] = &[6];
  16. }
  17.  
  18. fn main() {
  19. assert_eq!(5, i32::ID[0]);
  20. assert_eq!(6, i64::ID[1]);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement