Skip to content

Commit

Permalink
lli - Clippy fixes
Browse files Browse the repository at this point in the history
Signed-off-by: lli <[email protected]>
  • Loading branch information
lukewli-anonyome committed Jan 11, 2024
1 parent ab222be commit 9b411bd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions aries/aries_vcx/src/handlers/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ 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,
format!("Attachment is not base 64 encoded JSON: {:?}", attach),
))
};

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
}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ impl WalletStorage for MySqlStorage {
)
.bind(self.wallet_id)
.map(|r: MySqlRow| -> IndyResult<StorageRecord> {
let type_: String = r.get(0);
let type_: String = r.first();
let id: String = r.get(1);
let value: Vec<u8> = r.get(2);
let tags: serde_json::Value = r.get(3);
Expand Down Expand Up @@ -638,7 +638,7 @@ impl WalletStorage for MySqlStorage {
let records: VecDeque<_> = query
.map(|r: MySqlRow| -> IndyResult<StorageRecord> {
let type_ = if options.retrieve_type {
let type_: String = r.get(0);
let type_: String = r.first();
Some(base64::decode(&type_)?)
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion did_core/did_doc/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
6 changes: 3 additions & 3 deletions did_core/did_doc_sov/tests/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Uri>().unwrap());
assert_eq!(
first_service.service_endpoint(),
Expand Down Expand Up @@ -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::<Uri>().unwrap());
assert_eq!(
first_service.service_endpoint(),
Expand Down Expand Up @@ -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::<Uri>().unwrap());
assert_eq!(
first_service.service_endpoint(),
Expand Down

0 comments on commit 9b411bd

Please sign in to comment.