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

Handle type error caused by returning specific type that would be solved by using impl Trait #61271

estebank opened this issue May 28, 2019 · 0 comments


Copy link

@estebank estebank commented May 28, 2019

When encountering a type error on the return expression not matching the return type, which is a type argument for a trait, try to evaluate the return expression as if the return type had been impl of the expected trait. If that would resolve the problem, suggest it.

error[E0308]: mismatched types
 --> src/
1 |   fn permute<'a, T, I>(sides: &'a [T]) -> I
  |                     - this type parameter - expected `I` because of return type
5 | /     sides.iter().enumerate().map(|(i, _)| {
6 | |         let window = sides.iter().cycle().skip(i);
7 | |         window.take(sides.len()).collect()
8 | |     })
  | |______^ expected type parameter `I`, found struct `std::iter::Map`
  = note: expected type parameter `I`
                     found struct `std::iter::Map<std::iter::Enumerate<std::slice::Iter<'_, T>>, [closure@src/ 8:6 sides:_]>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant