From d0502c4f6b6308382480f704d7bc761b31d6913b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 12 Aug 2021 17:06:19 +0200 Subject: [PATCH] crypto: Fix some clippy warnings --- rust-sdk/src/lib.rs | 10 +++++----- rust-sdk/src/machine.rs | 14 +++++++------- rust-sdk/src/responses.rs | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/rust-sdk/src/lib.rs b/rust-sdk/src/lib.rs index 7d93ac22b4..968632b914 100644 --- a/rust-sdk/src/lib.rs +++ b/rust-sdk/src/lib.rs @@ -93,12 +93,12 @@ impl From for CrossSigningKeyExport { } } -impl Into for CrossSigningKeyExport { - fn into(self) -> matrix_sdk_crypto::CrossSigningKeyExport { +impl From for matrix_sdk_crypto::CrossSigningKeyExport { + fn from(e: CrossSigningKeyExport) -> Self { matrix_sdk_crypto::CrossSigningKeyExport { - master_key: self.master_key, - self_signing_key: self.self_signing_key, - user_signing_key: self.user_signing_key, + master_key: e.master_key, + self_signing_key: e.self_signing_key, + user_signing_key: e.user_signing_key, } } } diff --git a/rust-sdk/src/machine.rs b/rust-sdk/src/machine.rs index 701baa0602..0b8e3cd7ba 100644 --- a/rust-sdk/src/machine.rs +++ b/rust-sdk/src/machine.rs @@ -287,7 +287,7 @@ impl OlmMachine { ) -> Result<(), CryptoStoreError> { let id = Uuid::parse_str(request_id).expect("Can't parse request id"); - let response = response_from_string(&response_body); + let response = response_from_string(response_body); let response: OwnedResponse = match request_type { RequestType::KeysUpload => { @@ -703,7 +703,7 @@ impl OlmMachine { let user_id = UserId::try_from(user_id).ok()?; let methods = methods .into_iter() - .map(|m| VerificationMethod::from(m)) + .map(VerificationMethod::from) .collect(); if let Some(verification) = self.inner.get_verification_request(&user_id, flow_id) { @@ -733,7 +733,7 @@ impl OlmMachine { let methods = methods .into_iter() - .map(|m| VerificationMethod::from(m)) + .map(VerificationMethod::from) .collect(); Ok(if let Some(identity) = identity.and_then(|i| i.other()) { @@ -781,7 +781,7 @@ impl OlmMachine { let methods = methods .into_iter() - .map(|m| VerificationMethod::from(m)) + .map(VerificationMethod::from) .collect(); Ok(if let Some(identity) = identity.and_then(|i| i.other()) { @@ -818,7 +818,7 @@ impl OlmMachine { let methods = methods .into_iter() - .map(|m| VerificationMethod::from(m)) + .map(VerificationMethod::from) .collect(); Ok( @@ -856,7 +856,7 @@ impl OlmMachine { let methods = methods .into_iter() - .map(|m| VerificationMethod::from(m)) + .map(VerificationMethod::from) .collect(); Ok(if let Some(identity) = identity.and_then(|i| i.own()) { @@ -1025,7 +1025,7 @@ impl OlmMachine { .get_verification(&user_id, flow_id) .and_then(|v| { v.qr_v1() - .and_then(|qr| qr.to_bytes().map(|b| encode(b)).ok()) + .and_then(|qr| qr.to_bytes().map(encode).ok()) }) } diff --git a/rust-sdk/src/responses.rs b/rust-sdk/src/responses.rs index 122324761c..693f4f1845 100644 --- a/rust-sdk/src/responses.rs +++ b/rust-sdk/src/responses.rs @@ -263,15 +263,15 @@ pub struct DeviceLists { pub left: Vec, } -impl Into for DeviceLists { - fn into(self) -> RumaDeviceLists { +impl From for RumaDeviceLists { + fn from(d: DeviceLists) -> Self { assign!(RumaDeviceLists::new(), { - changed: self + changed: d .changed .into_iter() .filter_map(|u| UserId::try_from(u).ok()) .collect(), - left: self + left: d .left .into_iter() .filter_map(|u| UserId::try_from(u).ok()) @@ -323,9 +323,9 @@ impl From for OwnedResponse { } } -impl<'a> Into> for &'a OwnedResponse { - fn into(self) -> IncomingResponse<'a> { - match self { +impl<'a> From<&'a OwnedResponse> for IncomingResponse<'a> { + fn from(r: &'a OwnedResponse) -> Self { + match r { OwnedResponse::KeysClaim(r) => IncomingResponse::KeysClaim(r), OwnedResponse::KeysQuery(r) => IncomingResponse::KeysQuery(r), OwnedResponse::KeysUpload(r) => IncomingResponse::KeysUpload(r),