Guest User

Untitled

a guest
Jul 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #![allow(warnings)]
  2.  
  3. use std::fmt::Display;
  4.  
  5. struct Vector<T> where
  6. {
  7. components: T
  8. }
  9. impl<T> Vector<T> where
  10. {
  11. fn dot_product(self) where
  12. T: Iterator
  13. {
  14. //use functions from the Iterator trait such that we can iterate over the internal data T
  15. }
  16.  
  17. fn print(self) where
  18. T: Iterator,
  19. T::Item: Display,
  20. {
  21. //use functions from the Display trait such that we can print the internal data T
  22. for x in self.components
  23. {
  24. println!("{}", x);
  25. }
  26. }
  27. }
  28.  
  29. fn main()
  30. {
  31. let y = Vector{components: vec![1, 2].into_iter()};
  32. y.print();
  33. y.print();
  34. }
Add Comment
Please, Sign In to add comment