From 0df782e93ee2d9d9c338775adbe2cf1b35048740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 4 Jun 2021 18:49:08 +0200 Subject: [PATCH] crypto: Fix some clippy warnings --- matrix_sdk_crypto/src/verification/cache.rs | 1 + matrix_sdk_crypto/src/verification/machine.rs | 5 ++--- matrix_sdk_crypto/src/verification/requests.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/matrix_sdk_crypto/src/verification/cache.rs b/matrix_sdk_crypto/src/verification/cache.rs index 1d9ad673..1d42b711 100644 --- a/matrix_sdk_crypto/src/verification/cache.rs +++ b/matrix_sdk_crypto/src/verification/cache.rs @@ -35,6 +35,7 @@ impl VerificationCache { } #[cfg(test)] + #[allow(dead_code)] pub fn is_empty(&self) -> bool { self.verification.is_empty() } diff --git a/matrix_sdk_crypto/src/verification/machine.rs b/matrix_sdk_crypto/src/verification/machine.rs index e12e92ad..e569321c 100644 --- a/matrix_sdk_crypto/src/verification/machine.rs +++ b/matrix_sdk_crypto/src/verification/machine.rs @@ -371,7 +371,7 @@ mod test { ); machine - .receive_any_event(&wrap_any_to_device_content(bob_sas.user_id(), start_content.into())) + .receive_any_event(&wrap_any_to_device_content(bob_sas.user_id(), start_content)) .await .unwrap(); @@ -405,8 +405,7 @@ mod test { alice_machine.receive_any_event(&event).await.unwrap(); assert!(!alice_machine.verifications.outgoing_requests().is_empty()); - let request = - alice_machine.verifications.outgoing_requests().iter().next().unwrap().clone(); + let request = alice_machine.verifications.outgoing_requests().get(0).cloned().unwrap(); let txn_id = *request.request_id(); let content = OutgoingContent::try_from(request).unwrap(); let content = KeyContent::try_from(&content).unwrap().into(); diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index a0ce3bba..77556ca9 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -248,14 +248,14 @@ impl VerificationRequest { pub(crate) fn receive_done(&self, sender: &UserId, content: &DoneContent<'_>) { if sender == self.other_user() { let mut inner = self.inner.lock().unwrap().clone(); - inner.into_done(content); + inner.receive_done(content); } } pub(crate) fn receive_cancel(&self, sender: &UserId, content: &CancelContent<'_>) { if sender == self.other_user() { let mut inner = self.inner.lock().unwrap().clone(); - inner.into_canceled(content.cancel_code()); + inner.cancel(content.cancel_code()); } } @@ -336,7 +336,7 @@ impl InnerRequest { } } - fn into_done(&mut self, content: &DoneContent) { + fn receive_done(&mut self, content: &DoneContent) { *self = InnerRequest::Done(match self { InnerRequest::Created(s) => s.clone().into_done(content), InnerRequest::Requested(s) => s.clone().into_done(content), @@ -347,7 +347,7 @@ impl InnerRequest { }) } - fn into_canceled(&mut self, cancel_code: &CancelCode) { + fn cancel(&mut self, cancel_code: &CancelCode) { *self = InnerRequest::Cancelled(match self { InnerRequest::Created(s) => s.clone().into_canceled(cancel_code), InnerRequest::Requested(s) => s.clone().into_canceled(cancel_code),