Skip to content

Commit d81eabc

Browse files
authored
Merge pull request #822 from m5tfi/main
fixes #821: remove #[allow[clippy::from_over_into] and change to From
2 parents c763969 + d7f9f95 commit d81eabc

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

src/redirect.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,16 @@ where
9696
}
9797
}
9898

99-
#[allow(clippy::from_over_into)]
100-
impl<T: AsRef<str>> Into<Response> for Redirect<T> {
101-
fn into(self) -> Response {
102-
(&self).into()
99+
impl<T: AsRef<str>> From<Redirect<T>> for Response {
100+
fn from(redirect: Redirect<T>) -> Response {
101+
redirect.into()
103102
}
104103
}
105104

106-
#[allow(clippy::from_over_into)]
107-
impl<T: AsRef<str>> Into<Response> for &Redirect<T> {
108-
fn into(self) -> Response {
109-
let mut res = Response::new(self.status);
110-
res.insert_header(LOCATION, self.location.as_ref());
105+
impl<T: AsRef<str>> From<&Redirect<T>> for Response {
106+
fn from(redirect: &Redirect<T>) -> Response {
107+
let mut res = Response::new(redirect.status);
108+
res.insert_header(LOCATION, redirect.location.as_ref());
111109
res
112110
}
113111
}

src/request.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -557,25 +557,22 @@ impl<State> Read for Request<State> {
557557
}
558558
}
559559

560-
#[allow(clippy::from_over_into)]
561-
impl<State> Into<http::Request> for Request<State> {
562-
fn into(self) -> http::Request {
563-
self.req
560+
impl<State> From<Request<State>> for http::Request {
561+
fn from(request: Request<State>) -> http::Request {
562+
request.req
564563
}
565564
}
566565

567-
#[allow(clippy::from_over_into)]
568-
impl<State: Default> Into<Request<State>> for http_types::Request {
569-
fn into(self) -> Request<State> {
570-
Request::new(State::default(), self, Vec::<Params>::new())
566+
impl<State: Default> From<http_types::Request> for Request<State> {
567+
fn from(request: http_types::Request) -> Request<State> {
568+
Request::new(State::default(), request, Vec::<Params>::new())
571569
}
572570
}
573571

574-
#[allow(clippy::from_over_into)]
575-
impl<State: Clone + Send + Sync + 'static> Into<Response> for Request<State> {
576-
fn into(mut self) -> Response {
572+
impl<State: Clone + Send + Sync + 'static> From<Request<State>> for Response {
573+
fn from(mut request: Request<State>) -> Response {
577574
let mut res = Response::new(StatusCode::Ok);
578-
res.set_body(self.take_body());
575+
res.set_body(request.take_body());
579576
res
580577
}
581578
}

src/response.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl Response {
301301
/// Sets the response's error, overwriting any existing error.
302302
///
303303
/// This is particularly useful for middleware which would like to notify further
304-
/// middleware that an error has occured without overwriting the existing response.
304+
/// middleware that an error has occurred without overwriting the existing response.
305305
pub fn set_error(&mut self, error: impl Into<Error>) {
306306
self.error = Some(error.into());
307307
}
@@ -356,10 +356,9 @@ impl AsMut<http::Headers> for Response {
356356
}
357357
}
358358

359-
#[allow(clippy::from_over_into)]
360-
impl Into<http::Response> for Response {
361-
fn into(self) -> http_types::Response {
362-
self.res
359+
impl From<Response> for http::Response {
360+
fn from(response: Response) -> http_types::Response {
361+
response.res
363362
}
364363
}
365364

src/response_builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ impl ResponseBuilder {
7777
}
7878
}
7979

80-
#[allow(clippy::from_over_into)]
81-
impl Into<Response> for ResponseBuilder {
82-
fn into(self) -> Response {
83-
self.build()
80+
impl From<ResponseBuilder> for Response {
81+
fn from(response_builder: ResponseBuilder) -> Response {
82+
response_builder.build()
8483
}
8584
}

0 commit comments

Comments
 (0)