Remove &E argument from with_context signature

This commit is contained in:
David Tolnay 2019-10-05 00:14:48 -04:00
parent 895d3834e5
commit dc003568d7
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -15,7 +15,7 @@ pub trait Context<T, E> {
fn with_context<C, F>(self, f: F) -> Result<T, Error> fn with_context<C, F>(self, f: F) -> Result<T, Error>
where where
C: Display + Send + Sync + 'static, C: Display + Send + Sync + 'static,
F: FnOnce(&E) -> C; F: FnOnce() -> C;
} }
impl<T, E> Context<T, E> for Result<T, E> impl<T, E> Context<T, E> for Result<T, E>
@ -32,11 +32,11 @@ where
fn with_context<C, F>(self, f: F) -> Result<T, Error> fn with_context<C, F>(self, f: F) -> Result<T, Error>
where where
C: Display + Send + Sync + 'static, C: Display + Send + Sync + 'static,
F: FnOnce(&E) -> C, F: FnOnce() -> C,
{ {
self.map_err(|error| { self.map_err(|error| {
Error::from(ContextError { Error::from(ContextError {
context: f(&error), context: f(),
error, error,
}) })
}) })
@ -54,11 +54,11 @@ impl<T> Context<T, Error> for Result<T, Error> {
fn with_context<C, F>(self, f: F) -> Result<T, Error> fn with_context<C, F>(self, f: F) -> Result<T, Error>
where where
C: Display + Send + Sync + 'static, C: Display + Send + Sync + 'static,
F: FnOnce(&Error) -> C, F: FnOnce() -> C,
{ {
self.map_err(|error| { self.map_err(|error| {
Error::from(ContextError { Error::from(ContextError {
context: f(&error), context: f(),
error, error,
}) })
}) })