Use DoubleEndedIterator instead of collect to Vec for reversing

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
This commit is contained in:
Philipp Mildenberger 2023-03-18 17:00:57 +01:00
parent dd2f74794a
commit 0637691eb1
2 changed files with 1 additions and 3 deletions

View file

@ -3076,8 +3076,6 @@ fn goto_prev_diag(cx: &mut Context) {
let diag = doc
.shown_diagnostics()
.collect::<Vec<_>>()
.into_iter()
.rev()
.find(|diag| diag.range.start < cursor_pos)
.or_else(|| doc.shown_diagnostics().last());

View file

@ -1607,7 +1607,7 @@ impl Document {
&self.diagnostics
}
pub fn shown_diagnostics(&self) -> impl Iterator<Item = &Diagnostic> {
pub fn shown_diagnostics(&self) -> impl Iterator<Item = &Diagnostic> + DoubleEndedIterator {
let ls_ids: HashSet<_> = self
.language_servers_with_feature(LanguageServerFeature::Diagnostics)
.iter()