Open
Description
This code doesn't compile:
pub struct Thing {
chars: Box<dyn Iterator<Item = char>>,
}
impl Thing {
pub fn new(string: &str) -> Self {
Thing {
chars: Box::new(string.chars()),
}
}
fn next_char(&mut self) -> Option<char> {
self.chars.next()
}
}
Fixing it involves adding a lifetime bound with dyn Iterator<Item = char> + 'a
, but this syntax is not something a beginner would know. It would be nice if rustc suggested it.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: trait objects, vtable layoutArea: Lifetimes / regionsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.