Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upApply some idiomatic shortcuts #1
Comments
This comment has been minimized.
This comment has been minimized.
|
Thanks for taking the time to read the code and provide these pointers! I found them very helpful. I have now applied them to the code. There are some differences with what you suggested as I changed how I handle the errors. I will keep the issue open for some time if you want to have another look at some point. |
This comment has been minimized.
This comment has been minimized.
frol
commented
Dec 31, 2018
|
Lines 128 to 136 in bd8df56 let dir_filtered = dir.filter(|path_result| {
path_result
.ok()
.and_then(|path| path.file_name().to_str())
.filter(|entry| entry.starts_with(prefix))
.is_ok()
});Lines 138 to 143 in bd8df56 let mut paths: Vec<PathBuf> = dir_filtered
.map(|path_result| path_result.expect("Unexpected file path").path())
.collect();I would also move Line 43 in a6d3690 out of the loop and only call It also better to use
|
This comment has been minimized.
This comment has been minimized.
frol
commented
Dec 31, 2018
added a commit
that referenced
this issue
Jan 2, 2019
This comment has been minimized.
This comment has been minimized.
|
Thanks for the further comments! I've applied all your new suggestions. However, your suggestion to fix In the end, by rewriting the two blocks slightly differently, I did get it to work using Lines 128 to 143 in a6d3690 I went to this Lines 128 to 139 in ce2fe13 Here, I do use And I haven't been using |
This comment has been minimized.
This comment has been minimized.
frol
commented
Jan 2, 2019
|
I am glad my tips helped you! Good luck! |
frol commentedDec 30, 2018
•
edited
rwmstatus/src/main.rs
Line 42 in 676830f
I would use
display.is_null()rwmstatus/src/lib.rs
Lines 30 to 35 in 676830f
There is a built-in
std::fs::read_to_stringHere are a few shortcuts:
rwmstatus/src/lib.rs
Lines 68 to 75 in 676830f
rwmstatus/src/lib.rs
Lines 77 to 85 in 676830f
rwmstatus/src/lib.rs
Lines 87 to 90 in 676830f