From b2d8cce90a50e7e68d425a6c692ce401d63de171 Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Sat, 23 Jan 2016 17:18:39 +0100 Subject: Fix compilation, fix dependencies --- src/format/energymech.rs | 8 ++++---- src/format/mod.rs | 30 +++++++++++++++--------------- src/format/weechat3.rs | 8 ++++---- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/format') diff --git a/src/format/energymech.rs b/src/format/energymech.rs index 5965dfa..ba82458 100644 --- a/src/format/energymech.rs +++ b/src/format/energymech.rs @@ -153,8 +153,8 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> Decode<'a> for Energymech { - fn decode(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { +impl Decode for Energymech { + fn decode<'a>(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { Box::new(Iter { context: context, input: input, @@ -163,8 +163,8 @@ impl<'a> Decode<'a> for Energymech { } } -impl<'a, W> Encode<'a, W> for Energymech where W: Write { - fn encode(&'a self, context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> { +impl Encode for Energymech { + fn encode<'a>(&'a self, context: &'a Context, mut output: &'a mut Write, event: &'a Event) -> ::Result<()> { match event { &Event { ty: Type::Msg { ref from, ref content }, ref time, .. } => { try!(writeln!(&mut output, "[{}] <{}> {}", diff --git a/src/format/mod.rs b/src/format/mod.rs index 4f8eaa1..370a92b 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -23,41 +23,41 @@ use std::borrow::Cow; use event::Event; use context::Context; -//pub mod weechat3; -//pub mod energymech; +pub mod energymech; +pub mod weechat3; //pub mod binary; //pub mod msgpack; -pub trait Encode<'a, W> where W: Write { - fn encode(&'a self, context: &'a Context, output: W, event: &'a Event) -> ::Result<()>; +pub trait Encode { + fn encode<'a>(&'a self, context: &'a Context, output: &'a mut Write, event: &'a Event) -> ::Result<()>; } -pub trait Decode<'a, 'b, 'c> { - fn decode(&'a mut self, context: &'b Context, input: &'c mut BufRead) -> Box>> + 'a>; +pub trait Decode { + fn decode<'a>(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a>; } pub struct Dummy; -impl <'a, 'b, 'c> Decode<'a, 'b, 'c> for Dummy { - fn decode(&'a mut self, _context: &'b Context, _input: &'c mut BufRead) -> Box>> + 'a> { +impl Decode for Dummy { + fn decode<'a>(&'a mut self, _context: &'a Context, _input: &'a mut BufRead) -> Box>> + 'a> { Box::new(iter::empty()) } } -pub fn decoder<'a, 'b, 'c>(format: &str) -> Option>> { +pub fn decoder(format: &str) -> Option> { match format { -// "energymech" => Some(Box::new(energymech::Energymech)), -// "weechat3" => Some(Box::new(weechat3::Weechat3)), + "energymech" => Some(Box::new(energymech::Energymech)), + "weechat3" => Some(Box::new(weechat3::Weechat3)), // "binary" => Some(Box::new(binary::Binary)), // "msgpack" => Some(Box::new(msgpack::Msgpack)), _ => None } } -pub fn encoder<'a, 'b: 'a>(format: &str) -> Option>> { +pub fn encoder(format: &str) -> Option> { match format { -// "energymech" => Some(Box::new(energymech::Energymech)), -// "weechat3" => Some(Box::new(weechat3::Weechat3)), + "energymech" => Some(Box::new(energymech::Energymech)), + "weechat3" => Some(Box::new(weechat3::Weechat3)), // "binary" => Some(Box::new(binary::Binary)), // "msgpack" => Some(Box::new(msgpack::Msgpack)), _ => None @@ -65,7 +65,7 @@ pub fn encoder<'a, 'b: 'a>(format: &str) -> Option } fn rejoin(s: &[&str], splits: &[char]) -> Cow<'static, str> { - let len = s.iter().map(|s| s.len()).sum(); + let len = s.iter().map(|s| s.len()).fold(0, |a, b| a + b); let mut out = s.iter().zip(splits.iter()).fold(String::with_capacity(len), |mut s, (b, &split)| { s.push_str(b); s.push(split); s }); out.pop(); Cow::Owned(out) diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs index 118bd3b..92da0e0 100644 --- a/src/format/weechat3.rs +++ b/src/format/weechat3.rs @@ -139,8 +139,8 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> Decode<'a> for Weechat3 { - fn decode(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { +impl Decode for Weechat3 { + fn decode<'a>(&'a mut self, context: &'a Context, input: &'a mut BufRead) -> Box>> + 'a> { Box::new(Iter { context: context, input: input, @@ -149,8 +149,8 @@ impl<'a> Decode<'a> for Weechat3 { } } -impl<'a, W> Encode<'a, W> for Weechat3 where W: Write { - fn encode(&'a self, context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> { +impl Encode for Weechat3 { + fn encode<'a>(&'a self, context: &'a Context, mut output: &'a mut Write, event: &'a Event) -> ::Result<()> { match event { &Event { ty: Type::Msg { ref from, ref content, .. }, ref time, .. } => { try!(writeln!(&mut output, "{}\t{}\t{}", -- cgit v1.2.3