Re: [PATCH 2 of 2] rust: leverage .expect() in place of .unwrap() + inline comment

2020-06-02 Thread Augie Fackler
On Mon, May 25, 2020 at 11:27:41PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1590415610 -32400
> #  Mon May 25 23:06:50 2020 +0900
> # Node ID a5b88a7c25d3d8a02cbb2c1b9293200ddb0e06ac
> # Parent  261fbbdabb261a44c0f82537f10abbcc0d85ace1
> rust: leverage .expect() in place of .unwrap() + inline comment

queued, thanks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2] rust: leverage .expect() in place of .unwrap() + inline comment

2020-05-25 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1590415610 -32400
#  Mon May 25 23:06:50 2020 +0900
# Node ID a5b88a7c25d3d8a02cbb2c1b9293200ddb0e06ac
# Parent  261fbbdabb261a44c0f82537f10abbcc0d85ace1
rust: leverage .expect() in place of .unwrap() + inline comment

For a better error indication in case we made a mistake.

diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -257,11 +257,9 @@ fn walk_explicit<'a>(
 } 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 @@ fn traverse_dir<'a>(
 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) {
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel