Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Type Inference in Iterator::sum() is not working well #36201

Closed
StefanoD opened this issue Sep 1, 2016 · 1 comment
Closed

Type Inference in Iterator::sum() is not working well #36201

StefanoD opened this issue Sep 1, 2016 · 1 comment
Labels
A-type-system Area: Type system T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@StefanoD
Copy link

StefanoD commented Sep 1, 2016

From this thread:

Example 1:

fn total1(a: &[u32]) -> u32 { // OK
    a.iter().sum()
}

fn total3(a: &[u32]) -> u32 { // Error
    a.iter().sum() + 5u32
}

fn main() {}

Example 2:

fn f() -> f64 { // Ok
   0.0f64 +  vec![1.0f64].into_iter().sum::<f64>()
}

fn f2() -> f64 { // Error
   0.0f64 +  vec![1.0f64].into_iter().sum()
}

fn main() {}

rust version: 1.11 stable

@steveklabnik steveklabnik added A-type-system Area: Type system T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Sep 1, 2016
@mbrubeck
Copy link
Contributor

mbrubeck commented Mar 8, 2017

Possibly duplicate or related to #25094.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-type-system Area: Type system T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants