From 6b1daeba0533516c6d50fd2cebcc1e8060fd6df2 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 27 Mar 2021 14:19:57 +0000 Subject: [PATCH] Implement `From` over `Into` https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into --- src/api/core/two_factor/u2f.rs | 10 +++++----- src/auth.rs | 30 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/api/core/two_factor/u2f.rs b/src/api/core/two_factor/u2f.rs index 7934ab63..f841240b 100644 --- a/src/api/core/two_factor/u2f.rs +++ b/src/api/core/two_factor/u2f.rs @@ -131,12 +131,12 @@ struct RegisterResponseCopy { pub error_code: Option, } -impl Into for RegisterResponseCopy { - fn into(self) -> RegisterResponse { +impl From for RegisterResponse { + fn from(r: RegisterResponseCopy) -> RegisterResponse { RegisterResponse { - registration_data: self.registration_data, - version: self.version, - client_data: self.client_data, + registration_data: r.registration_data, + version: r.version, + client_data: r.client_data, } } } diff --git a/src/auth.rs b/src/auth.rs index 4041cc6b..d1398bbf 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -450,12 +450,12 @@ impl<'a, 'r> FromRequest<'a, 'r> for AdminHeaders { } } -impl Into for AdminHeaders { - fn into(self) -> Headers { +impl From for Headers { + fn from(h: AdminHeaders) -> Headers { Headers { - host: self.host, - device: self.device, - user: self.user, + host: h.host, + device: h.device, + user: h.user, } } } @@ -529,12 +529,12 @@ impl<'a, 'r> FromRequest<'a, 'r> for ManagerHeaders { } } -impl Into for ManagerHeaders { - fn into(self) -> Headers { +impl From for Headers { + fn from(h: ManagerHeaders) -> Headers { Headers { - host: self.host, - device: self.device, - user: self.user, + host: h.host, + device: h.device, + user: h.user, } } } @@ -571,12 +571,12 @@ impl<'a, 'r> FromRequest<'a, 'r> for ManagerHeadersLoose { } } -impl Into for ManagerHeadersLoose { - fn into(self) -> Headers { +impl From for Headers { + fn from(h: ManagerHeadersLoose) -> Headers { Headers { - host: self.host, - device: self.device, - user: self.user, + host: h.host, + device: h.device, + user: h.user, } } }