##// END OF EJS Templates
rhg: fix `clippy` warnings...
Antoine Cezar -
r46010:fbc373b7 default
parent child Browse files
Show More
@@ -69,7 +69,7 pub struct CommandError {
69
69
70 impl CommandError {
70 impl CommandError {
71 /// Exist the process with the corresponding exit code.
71 /// Exist the process with the corresponding exit code.
72 pub fn exit(&self) -> () {
72 pub fn exit(&self) {
73 std::process::exit(self.kind.get_exit_code())
73 std::process::exit(self.kind.get_exit_code())
74 }
74 }
75
75
@@ -34,22 +34,18 impl Ui {
34 pub fn write_stdout(&self, bytes: &[u8]) -> Result<(), UiError> {
34 pub fn write_stdout(&self, bytes: &[u8]) -> Result<(), UiError> {
35 let mut stdout = self.stdout.lock();
35 let mut stdout = self.stdout.lock();
36
36
37 stdout
37 stdout.write_all(bytes).or_else(handle_stdout_error)?;
38 .write_all(bytes)
39 .or_else(|e| handle_stdout_error(e))?;
40
38
41 stdout.flush().or_else(|e| handle_stdout_error(e))
39 stdout.flush().or_else(handle_stdout_error)
42 }
40 }
43
41
44 /// Write bytes to stderr
42 /// Write bytes to stderr
45 pub fn write_stderr(&self, bytes: &[u8]) -> Result<(), UiError> {
43 pub fn write_stderr(&self, bytes: &[u8]) -> Result<(), UiError> {
46 let mut stderr = self.stderr.lock();
44 let mut stderr = self.stderr.lock();
47
45
48 stderr
46 stderr.write_all(bytes).or_else(handle_stderr_error)?;
49 .write_all(bytes)
50 .or_else(|e| handle_stderr_error(e))?;
51
47
52 stderr.flush().or_else(|e| handle_stderr_error(e))
48 stderr.flush().or_else(handle_stderr_error)
53 }
49 }
54 }
50 }
55
51
@@ -66,14 +62,12 impl<W: Write> StdoutBuffer<W> {
66
62
67 /// Write bytes to stdout buffer
63 /// Write bytes to stdout buffer
68 pub fn write_all(&mut self, bytes: &[u8]) -> Result<(), UiError> {
64 pub fn write_all(&mut self, bytes: &[u8]) -> Result<(), UiError> {
69 self.buf
65 self.buf.write_all(bytes).or_else(handle_stdout_error)
70 .write_all(bytes)
71 .or_else(|e| handle_stdout_error(e))
72 }
66 }
73
67
74 /// Flush bytes to stdout
68 /// Flush bytes to stdout
75 pub fn flush(&mut self) -> Result<(), UiError> {
69 pub fn flush(&mut self) -> Result<(), UiError> {
76 self.buf.flush().or_else(|e| handle_stdout_error(e))
70 self.buf.flush().or_else(handle_stdout_error)
77 }
71 }
78 }
72 }
79
73
@@ -88,9 +82,9 fn handle_stdout_error(error: io::Error)
88
82
89 stderr
83 stderr
90 .write_all(&[b"abort: ", error.to_string().as_bytes(), b"\n"].concat())
84 .write_all(&[b"abort: ", error.to_string().as_bytes(), b"\n"].concat())
91 .map_err(|e| UiError::StderrError(e))?;
85 .map_err(UiError::StderrError)?;
92
86
93 stderr.flush().map_err(|e| UiError::StderrError(e))?;
87 stderr.flush().map_err(UiError::StderrError)?;
94
88
95 Err(UiError::StdoutError(error))
89 Err(UiError::StdoutError(error))
96 }
90 }
General Comments 0
You need to be logged in to leave comments. Login now