diff --git a/actix-http/src/ws/proto.rs b/actix-http/src/ws/proto.rs index 6fa3debc..93468d23 100644 --- a/actix-http/src/ws/proto.rs +++ b/actix-http/src/ws/proto.rs @@ -1,7 +1,6 @@ use std::convert::{From, Into}; use std::fmt; -use self::OpCode::*; /// Operation codes as part of RFC6455. #[derive(Debug, Eq, PartialEq, Clone, Copy)] pub enum OpCode { @@ -29,6 +28,7 @@ pub enum OpCode { impl fmt::Display for OpCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use self::OpCode::*; match *self { Continue => write!(f, "CONTINUE"), Text => write!(f, "TEXT"), @@ -41,9 +41,10 @@ impl fmt::Display for OpCode { } } -impl Into<u8> for OpCode { - fn into(self) -> u8 { - match self { +impl From<OpCode> for u8 { + fn from(op: OpCode) -> u8 { + use self::OpCode::*; + match op { Continue => 0, Text => 1, Binary => 2, @@ -60,6 +61,7 @@ impl Into<u8> for OpCode { impl From<u8> for OpCode { fn from(byte: u8) -> OpCode { + use self::OpCode::*; match byte { 0 => Continue, 1 => Text, @@ -72,7 +74,6 @@ impl From<u8> for OpCode { } } -use self::CloseCode::*; /// Status code used to indicate why an endpoint is closing the `WebSocket` /// connection. #[derive(Debug, Eq, PartialEq, Clone, Copy)] @@ -138,9 +139,10 @@ pub enum CloseCode { Other(u16), } -impl Into<u16> for CloseCode { - fn into(self) -> u16 { - match self { +impl From<CloseCode> for u16 { + fn from(code: CloseCode) -> u16 { + use self::CloseCode::*; + match code { Normal => 1000, Away => 1001, Protocol => 1002, @@ -161,6 +163,7 @@ impl Into<u16> for CloseCode { impl From<u16> for CloseCode { fn from(code: u16) -> CloseCode { + use self::CloseCode::*; match code { 1000 => Normal, 1001 => Away, @@ -185,6 +188,7 @@ impl From<u16> for CloseCode { pub struct CloseReason { /// Exit code pub code: CloseCode, + /// Optional description of the exit code pub description: Option<String>, } diff --git a/awc/src/sender.rs b/awc/src/sender.rs index d4d3d9b7..ebf87e23 100644 --- a/awc/src/sender.rs +++ b/awc/src/sender.rs @@ -33,18 +33,18 @@ pub(crate) enum PrepForSendingError { Http(HttpError), } -impl Into<FreezeRequestError> for PrepForSendingError { - fn into(self) -> FreezeRequestError { - match self { +impl From<PrepForSendingError> for FreezeRequestError { + fn from(err: PrepForSendingError) -> FreezeRequestError { + match err { PrepForSendingError::Url(e) => FreezeRequestError::Url(e), PrepForSendingError::Http(e) => FreezeRequestError::Http(e), } } } -impl Into<SendRequestError> for PrepForSendingError { - fn into(self) -> SendRequestError { - match self { +impl From<PrepForSendingError> for SendRequestError { + fn from(err: PrepForSendingError) -> SendRequestError { + match err { PrepForSendingError::Url(e) => SendRequestError::Url(e), PrepForSendingError::Http(e) => SendRequestError::Http(e), } diff --git a/src/service.rs b/src/service.rs index e6f71ed0..b88dac46 100644 --- a/src/service.rs +++ b/src/service.rs @@ -416,9 +416,9 @@ impl<B> ServiceResponse<B> { } } -impl<B> Into<Response<B>> for ServiceResponse<B> { - fn into(self) -> Response<B> { - self.response +impl<B> From<ServiceResponse<B>> for Response<B> { + fn into(res: ServiceResponse<B>) -> Response<B> { + res.response } } diff --git a/src/types/either.rs b/src/types/either.rs index 9f1d81a0..3d4d6bf0 100644 --- a/src/types/either.rs +++ b/src/types/either.rs @@ -121,13 +121,13 @@ pub enum EitherExtractError<A, B> { Extract(A, B), } -impl<A, B> Into<Error> for EitherExtractError<A, B> +impl<A, B> From<EitherExtractError<A, B>> for Error where A: Into<Error>, B: Into<Error>, { - fn into(self) -> Error { - match self { + fn into(err: EitherExtractError<A, B>) -> Error { + match err { EitherExtractError::Bytes(err) => err, EitherExtractError::Extract(a_err, _b_err) => a_err.into(), }