Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Type inference fails on FromIterator trait using basic range. #4132

Closed
cameron-rowe opened this issue Apr 25, 2020 · 1 comment
Closed

Type inference fails on FromIterator trait using basic range. #4132

cameron-rowe opened this issue Apr 25, 2020 · 1 comment
Labels
A-ty type system / type inference / traits / method resolution

Comments

@cameron-rowe
Copy link

The type inference of FromIterator seems to fail, even though the type of range is correctly deduced.

use std::iter::FromIterator;
fn main() {
    let v = Vec::from_iter(0..10);
    println!("v: {:?}", v);
}

image

Explicitly stating the type of the range seems to fix the issue.

use std::iter::FromIterator;
fn main() {
    let v = Vec::from_iter(0i32..10);
    println!("v: {:?}", v);
}

image

@bjorn3 bjorn3 added the A-ty type system / type inference / traits / method resolution label Apr 25, 2020
@flodiebold
Copy link
Member

Duplicate of #4072, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution
Projects
None yet
Development

No branches or pull requests

3 participants