Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #![feature(const_generics)]
  2.  
  3. use std::ops::Add;
  4.  
  5. struct VectorLike<T, const SIZE: usize>([T; {SIZE}]);
  6.  
  7. macro_rules! impl_operator_overload {
  8. ($trait_ident:ident, $method_ident:ident) => {
  9.  
  10. impl<T, const SIZE: usize> $trait_ident for VectorLike<T, {SIZE}>
  11. where
  12. T: $trait_ident,
  13. {
  14. type Output = VectorLike<T, {SIZE}>;
  15.  
  16. fn $method_ident(self, _: VectorLike<T, {SIZE}>) -> VectorLike<T, {SIZE}> {
  17. unimplemented!()
  18. }
  19. }
  20.  
  21. }
  22. }
  23.  
  24. impl_operator_overload!(Add, add);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement