[Request] [+- ] D8955: rhg: fix clippy warnings
acezar (Antoine Cezar)
phabricator at mercurial-scm.org
Wed Aug 26 13:23:56 UTC 2020
acezar created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8955
AFFECTED FILES
rust/rhg/src/error.rs
rust/rhg/src/ui.rs
CHANGE DETAILS
diff --git a/rust/rhg/src/ui.rs b/rust/rhg/src/ui.rs
--- a/rust/rhg/src/ui.rs
+++ b/rust/rhg/src/ui.rs
@@ -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))
}
diff --git a/rust/rhg/src/error.rs b/rust/rhg/src/error.rs
--- a/rust/rhg/src/error.rs
+++ b/rust/rhg/src/error.rs
@@ -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())
}
To: acezar, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200826/6b90a3cf/attachment-0001.html>
More information about the Mercurial-patches
mailing list