# HG changeset patch # User Matt Johnston # Date 1490094829 -28800 # Node ID 87a78343140e0d229163250c45af52d5903f2b63 # Parent a85c0c9bc1fa48974edb5c16b6be91fd188c0257 Duration::sum works now diff -r a85c0c9bc1fa -r 87a78343140e rust/src/types.rs --- a/rust/src/types.rs Wed Mar 08 23:08:14 2017 +0800 +++ b/rust/src/types.rs Tue Mar 21 19:13:49 2017 +0800 @@ -243,9 +243,7 @@ let end = p.end.unwrap_or_else(|| Instant::now()); end - p.start }); - // TODO rust 1.16: impl Sum for Duration - // durs.sum() - durs.fold(Duration::new(0,0), |acc, d| acc + d) + durs.sum() } fn trim(&mut self) { @@ -268,13 +266,12 @@ /// Takes a stream and returns a stream without errors. pub fn consume_errors(s: S) -> Box> -// XXX not sure why 'static is really necessary here? where S: Stream+Send+'static, ::Error: std::fmt::Display+Send+'static, ::Item: Send+'static, - { - s.then(|r| { +{ + let f = s.then(|r| { match r { Ok(v) => Ok(Some(v)), Err(e) => { @@ -283,5 +280,6 @@ } } }) - .filter_map(|p| p).boxed() + .filter_map(|p| p); + Box::new(f) }