Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(warnings)]
- use std::fmt::Display;
- struct Vector<T> where
- {
- components: T
- }
- impl<T> Vector<T> where
- {
- fn dot_product(self) where
- T: Iterator
- {
- //use functions from the Iterator trait such that we can iterate over the internal data T
- }
- fn print(self) where
- T: Iterator,
- T::Item: Display,
- {
- //use functions from the Display trait such that we can print the internal data T
- for x in self.components
- {
- println!("{}", x);
- }
- }
- }
- fn main()
- {
- let y = Vector{components: vec![1, 2].into_iter()};
- y.print();
- y.print();
- }
Add Comment
Please, Sign In to add comment