SHARE
TWEET

Untitled

a guest May 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trait ConstSize {
  2.     const N: usize;
  3. }
  4.  
  5. struct S8;
  6. impl ConstSize for S8 { const N: usize = 8; }
  7.  
  8. struct S24;
  9. impl ConstSize for S24 { const N: usize = 24; }
  10.  
  11. fn make_array<A, B>(a: A, b: B) -> [i32; <A as ConstSize>::N + <B as ConstSize>::N]
  12. where
  13.     A: ConstSize,
  14.     B: ConstSize,
  15. {
  16.     [0; <A as ConstSize>::N + <B as ConstSize>::N]
  17. }
  18.  
  19. fn main() {
  20.     let arr = make_array::<S8, S24>();
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top