rust: leverage .expect() in place of .unwrap() + inline comment
authorYuya Nishihara <yuya@tcha.org>
Mon, 25 May 2020 23:06:50 +0900
changeset 44926 14125dec0e39
parent 44925 ce8fe77102f4
child 44927 472b14da52c2
rust: leverage .expect() in place of .unwrap() + inline comment For a better error indication in case we made a mistake.
rust/hg-core/src/dirstate/status.rs
--- 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) {