rust: leverage .expect() in place of .unwrap() + inline comment
For a better error indication in case we made a mistake.
--- a/rust/hg-core/src/dirstate/status.rs Mon May 25 23:02:07 2020 +0900
+++ b/rust/hg-core/src/dirstate/status.rs Mon May 25 23:06:50 2020 +0900
@@ -257,11 +257,9 @@
} else {
if file_type.is_dir() {
if options.collect_traversed_dirs {
- // The receiver always outlives the sender,
- // so unwrap.
traversed_sender
.send(normalized.to_owned())
- .unwrap()
+ .expect("receiver should outlive sender");
}
Some(Ok((
normalized,
@@ -471,8 +469,9 @@
let directory = directory.as_ref();
if options.collect_traversed_dirs {
- // The receiver always outlives the sender, so unwrap.
- traversed_sender.send(directory.to_owned()).unwrap()
+ traversed_sender
+ .send(directory.to_owned())
+ .expect("receiver should outlive sender");
}
let visit_entries = match matcher.visit_children_set(directory) {