1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-01-20 05:58:08 +00:00

address clippy lints

This commit is contained in:
Rob Ede 2021-01-07 01:13:46 +00:00
parent 6d710629af
commit dc23559f23
No known key found for this signature in database
GPG key ID: C2A3B36E841A91E6
4 changed files with 24 additions and 20 deletions

View file

@ -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>,
}

View file

@ -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),
}

View file

@ -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
}
}

View file

@ -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(),
}