Code
fn process(items: impl IntoIterator<Item = String>) -> Vec<String> {
items.collect()
}
Current output
error[E0599]: `impl IntoIterator<Item = String>` is not an iterator
--> src/lib.rs:2:11
|
1 | fn process(items: impl IntoIterator<Item = String>) -> Vec<String> {
| -------------------------------- method `collect` not found for this type parameter
2 | items.collect()
| ^^^^^^^ `impl IntoIterator<Item = String>` is not an iterator
|
= note: the following trait bounds were not satisfied:
`impl IntoIterator<Item = String>: Iterator`
which is required by `&mut impl IntoIterator<Item = String>: Iterator`
help: consider restricting the type parameter to satisfy the trait bound
|
1 | fn process(items: impl IntoIterator<Item = String>) -> Vec<String> where impl IntoIterator<Item = String>: Iterator {
| ++++++++++++++++++++++++++++++++++++++++++++++++
Desired output
error[E0599]: `impl IntoIterator<Item = String>` is not an iterator
--> src/lib.rs:2:11
|
1 | fn process(items: impl IntoIterator<Item = String>) -> Vec<String> {
| -------------------------------- method `collect` not found for this type parameter
2 | items.collect()
| ^^^^^^^ `impl IntoIterator<Item = String>` is not an iterator
|
help: call `.into_iter()` first
|
2 | items.into_iter().collect()
| ++++++++++++
|
Rationale and extra context
It's an easy mistake that takes a moment to realize, so imo it would be cool to handle it better.
Other cases
No response
Anything else?
No response
Code
Current output
Desired output
Rationale and extra context
It's an easy mistake that takes a moment to realize, so imo it would be cool to handle it better.
Other cases
No response
Anything else?
No response