diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2015-04-06 17:43:50 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2015-04-08 00:26:35 +0200 |
| commit | 97f24a85965c3c51a2c18be029091ae52bbd7920 (patch) | |
| tree | 8e601d4b36ac0e3d1320482b959d42af6f8cb891 /src/libstd/old_path | |
| parent | 88427605bbd3271d52d064f339e344da2892b9cb (diff) | |
| download | rust-97f24a85965c3c51a2c18be029091ae52bbd7920.tar.gz rust-97f24a85965c3c51a2c18be029091ae52bbd7920.zip | |
Make `sum` and `product` inherent methods on `Iterator`
In addition to being nicer, this also allows you to use `sum` and `product` for iterators yielding custom types aside from the standard integers. Due to removing the `AdditiveIterator` and `MultiplicativeIterator` trait, this is a breaking change. [breaking-change]
Diffstat (limited to 'src/libstd/old_path')
| -rw-r--r-- | src/libstd/old_path/posix.rs | 5 | ||||
| -rw-r--r-- | src/libstd/old_path/windows.rs | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/libstd/old_path/posix.rs b/src/libstd/old_path/posix.rs index c517fab257f..af63be2aa9e 100644 --- a/src/libstd/old_path/posix.rs +++ b/src/libstd/old_path/posix.rs @@ -15,8 +15,7 @@ use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd}; use fmt; use hash; use old_io::Writer; -use iter::{AdditiveIterator, Extend}; -use iter::{Iterator, Map}; +use iter::{Extend, Iterator, Map}; use marker::Sized; use option::Option::{self, Some, None}; use result::Result::{self, Ok, Err}; @@ -351,7 +350,7 @@ impl Path { Some(vec![SEP_BYTE]) } else { let n = if is_abs { comps.len() } else { comps.len() - 1} + - comps.iter().map(|v| v.len()).sum(); + comps.iter().map(|v| v.len()).sum::<usize>(); let mut v = Vec::with_capacity(n); let mut it = comps.into_iter(); if !is_abs { diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs index 0b88f368b39..65aad38a2b4 100644 --- a/src/libstd/old_path/windows.rs +++ b/src/libstd/old_path/windows.rs @@ -20,8 +20,7 @@ use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd}; use fmt; use hash; use old_io::Writer; -use iter::{AdditiveIterator, Extend}; -use iter::{Iterator, Map, repeat}; +use iter::{Extend, Iterator, Map, repeat}; use mem; use option::Option::{self, Some, None}; use result::Result::{self, Ok, Err}; @@ -785,7 +784,7 @@ impl Path { let prefix_ = &s[..prefix_len(prefix)]; let n = prefix_.len() + if is_abs { comps.len() } else { comps.len() - 1} + - comps.iter().map(|v| v.len()).sum(); + comps.iter().map(|v| v.len()).sum::<usize>(); let mut s = String::with_capacity(n); match prefix { Some(DiskPrefix) => { |
