Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #![feature(const_generics)]
  2.  
  3. enum Node {
  4. A,
  5. B,
  6. }
  7.  
  8. struct Foo<const T: Node> {}
  9.  
  10. impl Foo<{ Node::A }> {
  11. fn nice(&self) {
  12. println!("nice");
  13. }
  14. }
  15.  
  16. impl Foo<{ Node::B }> {
  17. fn ok(&self) {
  18. println!("ok");
  19. }
  20. }
  21.  
  22. fn main() {
  23. let a: Foo<{ Node::A }> = Foo {};
  24. a.nice();
  25.  
  26. let b: Foo<{ Node::B }> = Foo {};
  27. b.ok();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement