about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2018-09-01 17:11:00 -0700
committerJosh Triplett <josh@joshtriplett.org>2018-09-01 17:14:39 -0700
commit40ea9999155bb4c48dc537ef066cb736956914e1 (patch)
treead6818406c81f2dd877df9cf63e1c4ec221d5e81
parent226d79c30aed5c0fb58c99047f88f98ac2eed689 (diff)
downloadrust-40ea9999155bb4c48dc537ef066cb736956914e1.tar.gz
rust-40ea9999155bb4c48dc537ef066cb736956914e1.zip
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.
-rw-r--r--src/tools/tidy/src/unstable_book.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/tools/tidy/src/unstable_book.rs b/src/tools/tidy/src/unstable_book.rs
index 62296f73f01..520879df620 100644
--- a/src/tools/tidy/src/unstable_book.rs
+++ b/src/tools/tidy/src/unstable_book.rs
@@ -56,12 +56,11 @@ pub fn collect_unstable_feature_names(features: &Features) -> BTreeSet<String> {
 pub fn collect_unstable_book_section_file_names(dir: &path::Path) -> BTreeSet<String> {
     fs::read_dir(dir)
         .expect("could not read directory")
-        .into_iter()
         .map(|entry| entry.expect("could not read directory entry"))
         .filter(dir_entry_is_file)
-        .map(|entry| entry.file_name().into_string().unwrap())
-        .filter(|n| n.ends_with(".md"))
-        .map(|n| n.trim_right_matches(".md").to_owned())
+        .map(|entry| entry.path())
+        .filter(|path| path.extension().map(|e| e.to_str().unwrap()) == Some("md"))
+        .map(|path| path.file_stem().unwrap().to_str().unwrap().into())
         .collect()
 }