Skip to content

Type inference doesn't work well with Iterators (0.11.0) #15673

Closed
@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions