diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-02-05 01:37:32 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-02-11 03:52:04 +0100 |
commit | 90eaeb642af712c6dc556ad8342e6d218c892cc1 (patch) | |
tree | 54764c60307db0bd7dd43c7c6fa222f98be545dd /lib/core | |
parent | 01fa19aadebbe94c6b759608e2f75f2714b74c94 (diff) |
Remove magic constants in trace_unwrap_exit/map_err_trace_exit_unwrap calls
This patch removes the magic constant we used when calling
`trace_unwrap_exit()` or `map_err_trace_exit_unwrap()`.
We used to call it with `1` as parameter, where the number was the exit
code to use. Now the implementation of the function does it
automatically (using 1 (one) as exit code).
All calls of these functions were fixed. Thanks to vim this was easy.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/libimagerror/src/iter.rs | 10 | ||||
-rw-r--r-- | lib/core/libimagerror/src/trace.rs | 6 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/core/libimagerror/src/iter.rs b/lib/core/libimagerror/src/iter.rs index 2c00a561..b146ebe4 100644 --- a/lib/core/libimagerror/src/iter.rs +++ b/lib/core/libimagerror/src/iter.rs @@ -59,7 +59,7 @@ impl<I, F, T> Iterator for UnwrapWith<I, F> /// Iterator helper for Unwrap with exiting on error -pub struct UnwrapExit<I, T>(I, i32) +pub struct UnwrapExit<I, T>(I) where I: Iterator<Item = Result<T, Error>>; impl<I, T> Iterator for UnwrapExit<I, T> @@ -69,7 +69,7 @@ impl<I, T> Iterator for UnwrapExit<I, T> fn next(&mut self) -> Option<Self::Item> { use trace::MapErrTrace; - self.0.next().map(|e| e.map_err_trace_exit_unwrap(self.1)) + self.0.next().map(|e| e.map_err_trace_exit_unwrap()) } } @@ -78,7 +78,7 @@ impl<I, T> DoubleEndedIterator for UnwrapExit<I, T> { fn next_back(&mut self) -> Option<Self::Item> { use trace::MapErrTrace; - self.0.next_back().map(|e| e.map_err_trace_exit_unwrap(self.1)) + self.0.next_back().map(|e| e.map_err_trace_exit_unwrap()) } } @@ -111,8 +111,8 @@ pub trait TraceIterator<T> : Iterator<Item = Result<T, Error>> + Sized { /// nothing will be passed to `::trace::trace_error_exit`, no matter how many `Err` items might /// be present. #[inline] - fn trace_unwrap_exit(self, exitcode: i32) -> UnwrapExit<Self, T> { - UnwrapExit(self, exitcode) + fn trace_unwrap_exit(self) -> UnwrapExit<Self, T> { + UnwrapExit(self) } diff --git a/lib/core/libimagerror/src/trace.rs b/lib/core/libimagerror/src/trace.rs index bad4e119..7894426c 100644 --- a/lib/core/libimagerror/src/trace.rs +++ b/lib/core/libimagerror/src/trace.rs @@ -73,7 +73,7 @@ pub trait MapErrTrace { type Output; fn map_err_trace(self) -> Self; - fn map_err_trace_exit_unwrap(self, code: i32) -> Self::Output; + fn map_err_trace_exit_unwrap(self) -> Self::Output; } impl<U> MapErrTrace for Result<U, Error> { @@ -87,8 +87,8 @@ impl<U> MapErrTrace for Result<U, Error> { } /// Trace the error and exit or unwrap the Ok(_). - fn map_err_trace_exit_unwrap(self, code: i32) -> Self::Output { - self.map_err(|e| { trace_error(&e); exit(code) }).unwrap() + fn map_err_trace_exit_unwrap(self) -> Self::Output { + self.map_err(|e| { trace_error(&e); exit(1) }).unwrap() } } |