1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
extern crate frappe;
extern crate ropey;

pub mod buffer;
pub mod history;
pub mod cursor;
pub mod jump;

pub use buffer::Buffer;
pub use history::History;
pub use cursor::Cursor;

trait EventSource {
    type Event;

    fn events(&self) -> frappe::Stream<Self::Event>;
}

/// Easier than returning a `std::iter::Map`.
pub struct Samples<'a, T: 'a + Clone> {
    items: &'a [frappe::Signal<T>],
    idx: usize
}

impl<'a, T: 'a + Clone> Iterator for Samples<'a, T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        if self.idx < self.items.len() {
            let item = self.items[self.idx].sample();
            self.idx += 1;
            Some(item)
        } else {
            None
        }
    }
}