Created
November 18, 2014 04:37
-
-
Save rrichardson/2f59de5429ac4539013f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Subscriber<Input> { | |
... | |
trait OutputStrategy<'a, Output> { | |
fn can_continue(&self) -> bool; | |
fn send(&self, val: Result<Output, &str>); | |
fn accept(&mut self, sub: &'a Subscriber<Output> +'a) -> Option<uint>; | |
} | |
impl<'a, O> OutputStrategy<'a, O> for SingleOutputStrategy<'a, O> { | |
fn accept(&mut self, sub: &'a Subscriber<O>) -> Option<uint> { | |
match self.subscriber { | |
Some(_) => { sub.on_error("SubscriptionsFull"); | |
None } | |
None => { self.subscriber = Some((Subscription::new(), sub)); | |
sub.on_subscribe(self.subscriber.as_ref().unwrap().ref0()); | |
Some(1) } | |
} | |
} | |
... | |
} | |
impl<'a, 'b, I, O, Iter> Publisher<'a, O> for IterPublisher<'a, 'b, I, O, Iter> where Iter: Iterator<I> { | |
fn subscribe(&mut self, s: &'a Subscriber<O> +'a ) { | |
let st = &mut self.outstrategy; | |
match st.accept(s) { | |
Some(i) => { st.on_request(|i| self.request(i)); st.on_cancel(|| self.cancel()); } | |
None => {} | |
} | |
} | |
} | |
155:27 error: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements | |
match st.accept(s) { | |
^~~~~~~~~~~~ | |
159:6 help: consider using an explicit lifetime parameter as shown: fn subscribe(&mut self, s: &'a Subscriber<O>+ 'a) | |
fn subscribe(&mut self, s: &'a Subscriber<O> +'a ) { | |
let st = &mut self.outstrategy; | |
match st.accept(s) { | |
Some(i) => { st.on_request(|i| self.request(i)); st.on_cancel(|| self.cancel()); } | |
None => {} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment