| 1 | use std::marker::PhantomData; |
| 2 | |
| 3 | use {Source, Value}; |
| 4 | |
| 5 | /// A random sequence. |
| 6 | pub struct Sequence<'l, S: ?Sized, V> where S: Source + 'l, V: Value + 'l { |
| 7 | source: &'l mut S, |
| 8 | phantom: PhantomData<&'l V>, |
| 9 | } |
| 10 | |
| 11 | impl<'l, S, V> From<&'l mut S> for Sequence<'l, S, V> where S: Source, V: Value { |
| 12 | #[inline(always)] |
| 13 | fn from(source: &'l mut S) -> Self { |
| 14 | Sequence { source: source, phantom: PhantomData } |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | impl<'l, S, V> Iterator for Sequence<'l, S, V> where S: Source, V: Value { |
| 19 | type Item = V; |
| 20 | |
| 21 | #[inline(always)] |
| 22 | fn next(&mut self) -> Option<V> { |
| 23 | Some(self.source.read()) |
| 24 | } |
| 25 | } |