changeset 45439:fbc373b7cbc3

rhg: fix `clippy` warnings Differential Revision: https://phab.mercurial-scm.org/D8955
author Antoine Cezar <antoine.cezar@octobus.net>
date Thu, 13 Aug 2020 16:36:42 +0200
parents ed95ccc94333
children a6a000ab135b
files rust/rhg/src/error.rs rust/rhg/src/ui.rs
diffstat 2 files changed, 9 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/rust/rhg/src/error.rs	Tue Aug 04 16:11:23 2020 +0200
+++ b/rust/rhg/src/error.rs	Thu Aug 13 16:36:42 2020 +0200
@@ -69,7 +69,7 @@
 
 impl CommandError {
     /// Exist the process with the corresponding exit code.
-    pub fn exit(&self) -> () {
+    pub fn exit(&self) {
         std::process::exit(self.kind.get_exit_code())
     }
 
--- a/rust/rhg/src/ui.rs	Tue Aug 04 16:11:23 2020 +0200
+++ b/rust/rhg/src/ui.rs	Thu Aug 13 16:36:42 2020 +0200
@@ -34,22 +34,18 @@
     pub fn write_stdout(&self, bytes: &[u8]) -> Result<(), UiError> {
         let mut stdout = self.stdout.lock();
 
-        stdout
-            .write_all(bytes)
-            .or_else(|e| handle_stdout_error(e))?;
+        stdout.write_all(bytes).or_else(handle_stdout_error)?;
 
-        stdout.flush().or_else(|e| handle_stdout_error(e))
+        stdout.flush().or_else(handle_stdout_error)
     }
 
     /// Write bytes to stderr
     pub fn write_stderr(&self, bytes: &[u8]) -> Result<(), UiError> {
         let mut stderr = self.stderr.lock();
 
-        stderr
-            .write_all(bytes)
-            .or_else(|e| handle_stderr_error(e))?;
+        stderr.write_all(bytes).or_else(handle_stderr_error)?;
 
-        stderr.flush().or_else(|e| handle_stderr_error(e))
+        stderr.flush().or_else(handle_stderr_error)
     }
 }
 
@@ -66,14 +62,12 @@
 
     /// Write bytes to stdout buffer
     pub fn write_all(&mut self, bytes: &[u8]) -> Result<(), UiError> {
-        self.buf
-            .write_all(bytes)
-            .or_else(|e| handle_stdout_error(e))
+        self.buf.write_all(bytes).or_else(handle_stdout_error)
     }
 
     /// Flush bytes to stdout
     pub fn flush(&mut self) -> Result<(), UiError> {
-        self.buf.flush().or_else(|e| handle_stdout_error(e))
+        self.buf.flush().or_else(handle_stdout_error)
     }
 }
 
@@ -88,9 +82,9 @@
 
     stderr
         .write_all(&[b"abort: ", error.to_string().as_bytes(), b"\n"].concat())
-        .map_err(|e| UiError::StderrError(e))?;
+        .map_err(UiError::StderrError)?;
 
-    stderr.flush().map_err(|e| UiError::StderrError(e))?;
+    stderr.flush().map_err(UiError::StderrError)?;
 
     Err(UiError::StdoutError(error))
 }