diff options
author | Till Hoeppner | 2015-04-04 23:10:47 +0200 |
---|---|---|
committer | Till Hoeppner | 2015-04-04 23:10:47 +0200 |
commit | c10547feed8f2b62a125e54d815440768e0d4d08 (patch) | |
tree | 5c3f9022dbf5857beb0aec5d4f0e6702be874600 | |
parent | 5fdac1cc6da07a800f944fa04d37f698bf296b8a (diff) | |
download | ilc-c10547feed8f2b62a125e54d815440768e0d4d08.tar.gz ilc-c10547feed8f2b62a125e54d815440768e0d4d08.tar.xz ilc-c10547feed8f2b62a125e54d815440768e0d4d08.zip |
Account for non-'blank' whitespace
-rw-r--r-- | src/format/weechat3.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs index f33847e..02602e0 100644 --- a/src/format/weechat3.rs +++ b/src/format/weechat3.rs @@ -24,10 +24,10 @@ impl<R> Iterator for Iter<R> where R: BufRead { fn timestamp(date: &str, time: &str) -> i64 { UTC.datetime_from_str(&format!("{} {}", date, time), TIME_DATE_FORMAT).unwrap().timestamp() } - fn join(s: &[&str]) -> String { + fn join(s: &[&str], splits: &[&str]) -> String { let len = s.iter().map(|s| s.len()).sum(); - let mut out = s.iter().fold(String::with_capacity(len), - |mut s, b| { s.push_str(b); s.push(' '); s }); + 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(); out } fn mask(s: &str) -> String { @@ -41,7 +41,8 @@ impl<R> Iterator for Iter<R> where R: BufRead { Ok(_) => () } - let tokens = self.buffer.split(|c: char| c.is_whitespace()).collect::<Vec<_>>(); + let mut split_tokens = Vec::new(); + let tokens = self.buffer.split(|c: char| { split_tokens.push(c); c.is_whitespace() }).collect::<Vec<_>>(); if log_enabled!(Info) { info!("Original: `{}`", self.buffer); info!("Parsing: {:?}", tokens); |