From 3be5734033b20c2476e6ca9154c3bb0e0ed840b2 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Sat, 2 Mar 2024 02:54:50 +0900 Subject: [PATCH] api: implement `FusedIterator` `IntoIter` and `FilterEntry` will return `None` once they returned `None`. Implementing `FusedIterator` allows `Iterator::fuse` method to be optimized. PR #139 --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index edf702e..4b96df4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; @@ -1001,6 +1002,8 @@ impl IntoIter { } } +impl iter::FusedIterator for IntoIter {} + impl DirList { fn close(&mut self) { if let DirList::Opened { .. } = *self { @@ -1083,6 +1086,11 @@ where } } +impl

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

FilterEntry where P: FnMut(&DirEntry) -> bool,