Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. use std::ops::Add;
  2.  
  3. #[derive(Copy)]
  4. struct Big {
  5. things: [u64; 100],
  6. }
  7.  
  8. impl Add<Big> for Big {
  9. type Output = Big;
  10.  
  11. #[inline(never)]
  12. fn add(self, rhs: Big) -> Big {
  13. let mut c = Big { things: [0; 100] };
  14. for i in 0..100 {
  15. c.things[i] = self.things[i] + rhs.things[i];
  16. }
  17. c
  18. }
  19. }
  20.  
  21. fn main() {
  22. let a = Big { things: [1; 100] };
  23. let b = Big { things: [2; 100] };
  24. let c = a + b;
  25.  
  26. //test::black_box(c);
  27. println!("{} + {} = {}", a.things[0], b.things[0], c.things[0])
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement