From f429b909db8624d9202e0e43c9732e957a7e93bc Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Thu, 11 Jun 2015 15:55:32 +0200 Subject: Reduction? --- src/format/weechat3.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs index 947bd61..164afc4 100644 --- a/src/format/weechat3.rs +++ b/src/format/weechat3.rs @@ -30,28 +30,27 @@ pub struct Weechat3; static TIME_DATE_FORMAT: &'static str = "%Y-%m-%d %H:%M:%S"; pub struct Iter<'a, R: 'a> where R: BufRead { - _phantom: PhantomData<&'a ()>, context: &'a Context, input: R, buffer: String } -impl<'a: 'b, 'b, R: 'a> Iterator for Iter<'a, R> where R: BufRead { +impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead { type Item = ::Result>; fn next(&mut self) -> Option<::Result>> { - fn parse_time<'b, 'c>(c: &Context, date: &'b str, time: &'c str) -> Time { + fn parse_time(c: &Context, date: &str, time: &str) -> Time { Time::from_format(&c.timezone, &format!("{} {}", date, time), TIME_DATE_FORMAT) } loop { - self.buffer.clear(); - match self.input.read_line(&mut self.buffer) { + let mut buffer = String::new(); + match self.input.read_line(&mut buffer) { Ok(0) | Err(_) => return None, Ok(_) => () } let mut split_tokens: Vec = Vec::new(); - let tokens: Vec<&'b str> = self.buffer.split(|c: char| { + let tokens = buffer.split(|c: char| { if c.is_whitespace() { split_tokens.push(c); true } else { false } }).collect::>(); @@ -60,7 +59,7 @@ impl<'a: 'b, 'b, R: 'a> Iterator for Iter<'a, R> where R: BufRead { info!("Parsing: {:?}", tokens); }*/ - match &tokens[..tokens.len() - 1] as &'b [&'b str] { + match &tokens[..tokens.len() - 1] { /*[date, time, "-->", nick, host, "has", "joined", channel, _..] => return Some(Ok(Event { ty: Type::Join { @@ -138,7 +137,6 @@ impl<'a: 'b, 'b, R: 'a> Iterator for Iter<'a, R> where R: BufRead { impl<'a, R: 'a> Decode<'static, R, Iter<'a, R>> for Weechat3 where R: BufRead { fn decode(&'a mut self, context: &'a Context, input: R) -> Iter { Iter { - _phantom: PhantomData, context: context, input: input, buffer: String::new() -- cgit v1.2.3