From 9b411bd10f39ab8bff86b9034e5df49c71245702 Mon Sep 17 00:00:00 2001 From: lli Date: Wed, 10 Jan 2024 17:03:06 -0800 Subject: [PATCH] lli - Clippy fixes Signed-off-by: lli --- aries/aries_vcx/src/handlers/util.rs | 8 ++++---- .../libvdrtools/indy-wallet/src/storage/mysql/mod.rs | 4 ++-- did_core/did_doc/tests/serde.rs | 2 +- did_core/did_doc_sov/tests/builder.rs | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/aries/aries_vcx/src/handlers/util.rs b/aries/aries_vcx/src/handlers/util.rs index e9b7898286..8c5a1a8045 100644 --- a/aries/aries_vcx/src/handlers/util.rs +++ b/aries/aries_vcx/src/handlers/util.rs @@ -46,7 +46,7 @@ macro_rules! matches_opt_thread_id { #[rustfmt::skip] // This macro results in some false positives and formatting makes it harder to read macro_rules! get_attach_as_string { ($attachments:expr) => {{ - let __attach = $attachments.get(0).as_ref().map(|a| &a.data.content); + let __attach = $attachments.first().as_ref().map(|a| &a.data.content); let err_fn = |attach: Option<&messages::decorators::attachment::Attachment>| { Err(AriesVcxError::from_msg( AriesVcxErrorKind::SerializationError, @@ -54,9 +54,9 @@ macro_rules! get_attach_as_string { )) }; - let Some(messages::decorators::attachment::AttachmentType::Base64(encoded_attach)) = __attach else { return err_fn($attachments.get(0)); }; - let Ok(bytes) = base64::engine::Engine::decode(&base64::engine::general_purpose::STANDARD, &encoded_attach) else { return err_fn($attachments.get(0)); }; - let Ok(attach_string) = String::from_utf8(bytes) else { return err_fn($attachments.get(0)); }; + let Some(messages::decorators::attachment::AttachmentType::Base64(encoded_attach)) = __attach else { return err_fn($attachments.first()); }; + let Ok(bytes) = base64::engine::Engine::decode(&base64::engine::general_purpose::STANDARD, &encoded_attach) else { return err_fn($attachments.first()); }; + let Ok(attach_string) = String::from_utf8(bytes) else { return err_fn($attachments.first()); }; attach_string }}; diff --git a/aries/misc/legacy/libvdrtools/indy-wallet/src/storage/mysql/mod.rs b/aries/misc/legacy/libvdrtools/indy-wallet/src/storage/mysql/mod.rs index f479e8fd1f..8ee51def1a 100644 --- a/aries/misc/legacy/libvdrtools/indy-wallet/src/storage/mysql/mod.rs +++ b/aries/misc/legacy/libvdrtools/indy-wallet/src/storage/mysql/mod.rs @@ -549,7 +549,7 @@ impl WalletStorage for MySqlStorage { ) .bind(self.wallet_id) .map(|r: MySqlRow| -> IndyResult { - let type_: String = r.get(0); + let type_: String = r.first(); let id: String = r.get(1); let value: Vec = r.get(2); let tags: serde_json::Value = r.get(3); @@ -638,7 +638,7 @@ impl WalletStorage for MySqlStorage { let records: VecDeque<_> = query .map(|r: MySqlRow| -> IndyResult { let type_ = if options.retrieve_type { - let type_: String = r.get(0); + let type_: String = r.first(); Some(base64::decode(&type_)?) } else { None diff --git a/did_core/did_doc/tests/serde.rs b/did_core/did_doc/tests/serde.rs index d7c6aeb3c9..bf8b452ab5 100644 --- a/did_core/did_doc/tests/serde.rs +++ b/did_core/did_doc/tests/serde.rs @@ -127,7 +127,7 @@ fn test_deserialization() { ) .build(); - assert_eq!(did_doc.verification_method().get(0).unwrap().clone(), vm1); + assert_eq!(did_doc.verification_method().first().unwrap().clone(), vm1); assert_eq!(did_doc.verification_method().get(1).unwrap().clone(), vm2); assert_eq!( diff --git a/did_core/did_doc_sov/tests/builder.rs b/did_core/did_doc_sov/tests/builder.rs index 57ec1e86e0..1918604d6a 100644 --- a/did_core/did_doc_sov/tests/builder.rs +++ b/did_core/did_doc_sov/tests/builder.rs @@ -26,7 +26,7 @@ fn test_service_build_aip1() { .build(); let services = did_doc.service(); assert_eq!(services.len(), 1); - let first_service = services.get(0).unwrap(); + let first_service = services.first().unwrap(); assert_eq!(first_service.id().clone(), ID.parse::().unwrap()); assert_eq!( first_service.service_endpoint(), @@ -56,7 +56,7 @@ fn test_service_build_didcommv1() { .build(); let services = did_doc.service(); assert_eq!(services.len(), 1); - let first_service = services.get(0).unwrap(); + let first_service = services.first().unwrap(); assert_eq!(first_service.id().clone(), ID.parse::().unwrap()); assert_eq!( first_service.service_endpoint(), @@ -90,7 +90,7 @@ fn test_service_build_didcommv2() { .build(); let services = did_doc.service(); assert_eq!(services.len(), 1); - let first_service = services.get(0).unwrap(); + let first_service = services.first().unwrap(); assert_eq!(first_service.id().clone(), ID.parse::().unwrap()); assert_eq!( first_service.service_endpoint(),