From 043e7ebb782caab52c6c1b507481de1e8eee6717 Mon Sep 17 00:00:00 2001 From: Andrew MacDonald Date: Wed, 29 Nov 2017 08:38:58 +1100 Subject: [PATCH] Use sum() since it is now part of standard rust It wasn't available when I was first working on this code, it is now, so hooray! Also implemented as sum:: since the type inference doesn't quite work in this context. Related discussion to this issue can be found on github here: https://github.com/rust-lang/rust/issues/25094 --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0f8daaf..4eea178 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,7 +69,7 @@ pub fn rmse(obs: &[f64], sim: &[f64]) -> f64 { */ pub fn nse(obs: &[f64], sim: &[f64]) -> f64 { - let m: f64 = obs.iter().fold(0f64, std::ops::Add::add) / (obs.len() as f64); + let m: f64 = obs.iter().sum::() / (obs.len() as f64); //int t; let mut e1: f64 = 0.0;