diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 04d039a5f..4944dae9b 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -1919,7 +1919,7 @@ pub unsafe extern "C" fn dc_get_contacts( let query = to_opt_string_lossy(query); block_on(async move { - match Contact::get_all(ctx, flags, query).await { + match Contact::get_all(ctx, flags, query.as_deref()).await { Ok(contacts) => Box::into_raw(Box::new(dc_array_t::from( contacts.iter().map(|id| id.to_u32()).collect::>(), ))), diff --git a/src/contact.rs b/src/contact.rs index 0260452df..853caccab 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -686,7 +686,7 @@ impl Contact { pub async fn get_all( context: &Context, listflags: u32, - query: Option>, + query: Option<&str>, ) -> Result> { let self_addrs = context.get_all_self_addrs().await?; let mut add_self = false; @@ -695,7 +695,7 @@ impl Contact { let flag_add_self = (listflags & DC_GCL_ADD_SELF) != 0; if flag_verified_only || query.is_some() { - let s3str_like_cmd = format!("%{}%", query.as_ref().map(|s| s.as_ref()).unwrap_or("")); + let s3str_like_cmd = format!("%{}%", query.unwrap_or("")); context .sql .query_map( @@ -739,9 +739,9 @@ impl Contact { .unwrap_or_default(); let self_name2 = stock_str::self_msg(context); - if self_addr.contains(query.as_ref()) - || self_name.contains(query.as_ref()) - || self_name2.await.contains(query.as_ref()) + if self_addr.contains(query) + || self_name.contains(query) + || self_name2.await.contains(query) { add_self = true; } @@ -1396,27 +1396,23 @@ pub fn normalize_name(full_name: &str) -> String { fn cat_fingerprint( ret: &mut String, addr: &str, - fingerprint_verified: impl AsRef, - fingerprint_unverified: impl AsRef, + fingerprint_verified: &str, + fingerprint_unverified: &str, ) { *ret += &format!( "\n\n{}:\n{}", addr, - if !fingerprint_verified.as_ref().is_empty() { - fingerprint_verified.as_ref() + if !fingerprint_verified.is_empty() { + fingerprint_verified } else { - fingerprint_unverified.as_ref() + fingerprint_unverified }, ); - if !fingerprint_verified.as_ref().is_empty() - && !fingerprint_unverified.as_ref().is_empty() - && fingerprint_verified.as_ref() != fingerprint_unverified.as_ref() + if !fingerprint_verified.is_empty() + && !fingerprint_unverified.is_empty() + && fingerprint_verified != fingerprint_unverified { - *ret += &format!( - "\n\n{} (alternative):\n{}", - addr, - fingerprint_unverified.as_ref() - ); + *ret += &format!("\n\n{} (alternative):\n{}", addr, fingerprint_unverified); } } diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index ee95c529f..f03f6bb24 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -2920,7 +2920,7 @@ mod tests { let chats = Chatlist::try_load(&t.ctx, 0, None, None).await?; assert_eq!(chats.len(), 1); - let contacts = Contact::get_all(&t.ctx, 0, None as Option).await?; + let contacts = Contact::get_all(&t.ctx, 0, None).await?; assert_eq!(contacts.len(), 0); // mailing list recipients and senders do not count as "known contacts" let msg1 = get_chat_msg(&t, chat_id, 0, 2).await; diff --git a/src/login_param.rs b/src/login_param.rs index 85c2e0e66..a83f83f78 100644 --- a/src/login_param.rs +++ b/src/login_param.rs @@ -150,8 +150,7 @@ impl LoginParam { } /// Read the login parameters from the database. - async fn from_database(context: &Context, prefix: impl AsRef) -> Result { - let prefix = prefix.as_ref(); + async fn from_database(context: &Context, prefix: &str) -> Result { let sql = &context.sql; let key = format!("{}addr", prefix);