Skip to content

Instantly share code, notes, and snippets.

@tomjakubowski
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomjakubowski/cdbc46fa8df368aae47e to your computer and use it in GitHub Desktop.
Save tomjakubowski/cdbc46fa8df368aae47e to your computer and use it in GitHub Desktop.
fn sum_vec_int<T: Num + Zero>(xs: &[T]) -> T {
let zero: T = Zero::zero();
xs.iter().fold(zero, |x, y| { x + *y })
}
sum_vec_int([1.0, 2.0, 3.0].as_slice());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment