1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-28 01:52:57 +01:00

fix clippy warning

This commit is contained in:
Nikolay Kim 2018-06-07 19:46:46 -07:00
parent f7bd6eeedc
commit 60d40df545

View File

@ -36,7 +36,7 @@ pub type Result<T, E = Error> = result::Result<T, E>;
/// General purpose actix web error. /// General purpose actix web error.
/// ///
/// An actix web error is used to carry errors from `failure` or `std::error` /// An actix web error is used to carry errors from `failure` or `std::error`
/// through actix in a convenient way. It can be created through through /// through actix in a convenient way. It can be created through through
/// converting errors with `into()`. /// converting errors with `into()`.
/// ///
@ -51,7 +51,9 @@ pub struct Error {
impl Error { impl Error {
/// Deprecated way to reference the underlying response error. /// Deprecated way to reference the underlying response error.
#[deprecated(since = "0.6.0", note = "please use `Error::as_response_error()` instead")] #[deprecated(
since = "0.6.0", note = "please use `Error::as_response_error()` instead"
)]
pub fn cause(&self) -> &ResponseError { pub fn cause(&self) -> &ResponseError {
self.cause.as_ref() self.cause.as_ref()
} }
@ -97,14 +99,14 @@ impl Error {
// //
// This currently requires a transmute. This could be avoided if failure // This currently requires a transmute. This could be avoided if failure
// provides a deref: https://github.com/rust-lang-nursery/failure/pull/213 // provides a deref: https://github.com/rust-lang-nursery/failure/pull/213
let compat: Option<&failure::Compat<failure::Error>> = Fail::downcast_ref(self.cause.as_fail()); let compat: Option<&failure::Compat<failure::Error>> =
Fail::downcast_ref(self.cause.as_fail());
if let Some(compat) = compat { if let Some(compat) = compat {
pub struct CompatWrappedError { pub struct CompatWrappedError {
error: failure::Error, error: failure::Error,
} }
let compat: &CompatWrappedError = unsafe { let compat: &CompatWrappedError =
::std::mem::transmute(compat) unsafe { &*(compat as *const _ as *const CompatWrappedError) };
};
compat.error.downcast_ref() compat.error.downcast_ref()
} else { } else {
None None
@ -126,8 +128,12 @@ pub trait InternalResponseErrorAsFail {
#[doc(hidden)] #[doc(hidden)]
impl<T: ResponseError> InternalResponseErrorAsFail for T { impl<T: ResponseError> InternalResponseErrorAsFail for T {
fn as_fail(&self) -> &Fail { self } fn as_fail(&self) -> &Fail {
fn as_mut_fail(&mut self) -> &mut Fail { self } self
}
fn as_mut_fail(&mut self) -> &mut Fail {
self
}
} }
/// Error that can be converted to `HttpResponse` /// Error that can be converted to `HttpResponse`