Skip to content

Commit 81a5793

Browse files
committed
Convert Into impls to From impls
To quote the `std::convert::From` doc: > One should always prefer implementing From over Into because > implementing From automatically provides one with an implementation of > Into thanks to the blanket implementation in the standard library.
1 parent 8ff0cae commit 81a5793

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/request.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ impl AsMut<Headers> for Request {
493493
}
494494
}
495495

496-
impl Into<Body> for Request {
497-
fn into(self) -> Body {
498-
self.body
496+
impl From<Request> for Body {
497+
fn from(req: Request) -> Body {
498+
req.body
499499
}
500500
}
501501

src/response.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ impl AsMut<Headers> for Response {
459459
}
460460
}
461461

462-
impl Into<Body> for Response {
463-
fn into(self) -> Body {
464-
self.body
462+
impl From<Response> for Body {
463+
fn from(res: Response) -> Body {
464+
res.body
465465
}
466466
}
467467

src/status_code.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,9 @@ impl StatusCode {
460460
}
461461
}
462462

463-
impl Into<u16> for StatusCode {
464-
fn into(self) -> u16 {
465-
self as u16
466-
}
467-
}
468-
469-
impl Into<u16> for &StatusCode {
470-
fn into(self) -> u16 {
471-
*self as u16
463+
impl From<StatusCode> for u16 {
464+
fn from(code: StatusCode) -> u16 {
465+
code as u16
472466
}
473467
}
474468

0 commit comments

Comments
 (0)