Skip to content

Commit 40ea999

Browse files
committed
tidy: unstable_book.rs: Clean up directory iteration
Drop unnecessary .into_iter() (also fixing a clippy warning), and use path functions to handle file extensions.
1 parent 226d79c commit 40ea999

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/tools/tidy/src/unstable_book.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ pub fn collect_unstable_feature_names(features: &Features) -> BTreeSet<String> {
5656
pub fn collect_unstable_book_section_file_names(dir: &path::Path) -> BTreeSet<String> {
5757
fs::read_dir(dir)
5858
.expect("could not read directory")
59-
.into_iter()
6059
.map(|entry| entry.expect("could not read directory entry"))
6160
.filter(dir_entry_is_file)
62-
.map(|entry| entry.file_name().into_string().unwrap())
63-
.filter(|n| n.ends_with(".md"))
64-
.map(|n| n.trim_right_matches(".md").to_owned())
61+
.map(|entry| entry.path())
62+
.filter(|path| path.extension().map(|e| e.to_str().unwrap()) == Some("md"))
63+
.map(|path| path.file_stem().unwrap().to_str().unwrap().into())
6564
.collect()
6665
}
6766

0 commit comments

Comments
 (0)