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
38
39
40
41
42
43
44
45
46
47
48
#![warn(missing_docs)]
#![feature(fn_traits, unboxed_closures)]
use std::iter::IntoIterator;
mod observable;
mod observer;
mod subject;
pub use observable::Observable;
pub use observer::Observer;
pub use subject::Subject;
pub struct UncancellableSubscription;
impl Drop for UncancellableSubscription {
fn drop(&mut self) { }
}
impl<'i, I> Observable for &'i I where &'i I: IntoIterator, <&'i I as IntoIterator>::Item: Clone {
type Item = <&'i I as IntoIterator>::Item;
type Error = ();
type Subscription = UncancellableSubscription;
fn subscribe<O>(&mut self, mut observer: O) -> UncancellableSubscription
where O: Observer<Self::Item, Self::Error> {
for x in self.into_iter() {
observer.on_next(x);
}
observer.on_completed();
UncancellableSubscription
}
}