Bound on iterator suggests invalid code to call iter()
on the impl
· Issue #121398 · rust-lang/rust (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
Code
pub struct Foo
where I: Iterator,
{
iter: I,
}
pub trait Bar: Iterator + Sized {
fn sprawl(self) -> Foo {
Foo {
iter: self
}
}
}
impl Bar for Vec where T: Iterator, {}
It suggests you to call iter()
on Vec<T>
in the impl, which is invalid code
Current output
Error[E0277]: Vec<T>
is not an iterator
--> src/lib.rs:17:19
|
17 | impl Bar for Vec
| ^^^^^^ Vec<T>
is not an iterator; try calling .into_iter()
or .iter()
|
= help: the trait Iterator
is not implemented for Vec<T>
note: required by a bound in Bar
--> src/lib.rs:9:18
|
9 | pub trait Bar: Iterator + Sized {
| ^^^^^^^^ required by this bound in Bar
For more information about this error, try rustc --explain E0277
.
Rationale and extra context
Rust Version
1.78.0 nightly, but also present on the latest nightly and stable