Example code:
use std::iter::AdditiveIterator;
fn main() {
let x: [u64, ..3] = [1, 2, 3];
println!("{}", range(0, 3).map(|i| x[i]).sum());
}
In this case, the type of the integers for the range is unambiguously uint, although the compiler still throws an error and won't accept the code unless you add a u suffix to either the 0 or the 3 in the range. This seems to apply to all types of iterators as well, and the compiler isn't good enough to infer the type based upon a later function call in the chain.
Example code:
In this case, the type of the integers for the
rangeis unambiguouslyuint, although the compiler still throws an error and won't accept the code unless you add ausuffix to either the0or the3in therange. This seems to apply to all types of iterators as well, and the compiler isn't good enough to infer the type based upon a later function call in the chain.