Skip to content

Commit

Permalink
api: implement FusedIterator
Browse files Browse the repository at this point in the history
`IntoIter` and `FilterEntry<IntoIter, P>` will return `None` once they
returned `None`. Implementing `FusedIterator` allows `Iterator::fuse`
method to be optimized.

PR #139
  • Loading branch information
lo48576 authored Mar 1, 2024
1 parent b0d16b7 commit 3be5734
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ use std::cmp::{min, Ordering};
use std::fmt;
use std::fs::{self, ReadDir};
use std::io;
use std::iter;
use std::path::{Path, PathBuf};
use std::result;
use std::vec;
Expand Down Expand Up @@ -1001,6 +1002,8 @@ impl IntoIter {
}
}

impl iter::FusedIterator for IntoIter {}

impl DirList {
fn close(&mut self) {
if let DirList::Opened { .. } = *self {
Expand Down Expand Up @@ -1083,6 +1086,11 @@ where
}
}

impl<P> iter::FusedIterator for FilterEntry<IntoIter, P> where
P: FnMut(&DirEntry) -> bool
{
}

impl<P> FilterEntry<IntoIter, P>
where
P: FnMut(&DirEntry) -> bool,
Expand Down

0 comments on commit 3be5734

Please sign in to comment.