SHARE
TWEET

Untitled

a guest Dec 16th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use num::Float;
  2.  
  3. struct MulIter<T,I>
  4.     where T : Float,
  5.           I : Iterator<Item = T>
  6.          
  7. {
  8.     iter: I,
  9.     scalar: T,
  10. }
  11.  
  12. impl<T, I> MulIter<T, I>
  13.     where T : Float,
  14.           I: Iterator<Item = T>,
  15. {
  16.     pub fn new(iter: I, scalar: T) -> MulIter<T, I> {
  17.         MulIter {
  18.             iter,
  19.             scalar,
  20.         }
  21.     }
  22. }
  23.  
  24. impl<T, I> Iterator for MulIter<T, I>
  25.     where T : Float,
  26.           I: Iterator<Item = T>,
  27. {
  28.     type Item = T;
  29.     fn next(&mut self) -> Option<T> {
  30.         match self.iter.next() {
  31.             Some(value) => Some(value * self.scalar),
  32.             None => None,
  33.         }
  34.     }
  35. }
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