Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. struct Struct {}
  2.  
  3. trait Trait {
  4. type S;
  5. const S:usize;
  6. }
  7. impl Trait for Struct {
  8. type S = i32;
  9. const S:usize = std::mem::size_of::<Struct>();
  10.  
  11. }
  12. /*
  13. fn i_from_slice<T:Trait>(slice: &[u8]) -> Option<T>
  14.  
  15. {
  16. match slice.len() {
  17. T::S => {
  18. let mut buf = [0; T::S];
  19. buf.copy_from_slice(slice);
  20. Some(unsafe { std::mem::transmute_copy(&buf) })
  21. }
  22. _ => None,
  23. }
  24. }
  25. */
  26. fn main() {
  27. println!("Hello, world!");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement