Guest User

Untitled

a guest
Jul 15th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #![feature(associated_consts)]
  2.  
  3. use std::marker::PhantomData;
  4.  
  5. trait Offset {
  6. const VALUE: usize;
  7. }
  8.  
  9. struct Weed<T> {
  10. _offset: PhantomData<T>
  11. }
  12.  
  13. impl<T> Weed<T> where T: Offset {
  14. pub fn speak() {
  15. println!("{}", T::VALUE);
  16. }
  17. }
  18.  
  19. trait OffsetImpl {
  20. const VALUE: i32 = 32;
  21. }
  22.  
  23. fn main() {
  24. Weed::<OffsetImpl>::speak();
  25. }
Add Comment
Please, Sign In to add comment