From 7a19963879d0382661635300507155a6fce0a6a8 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 22 Jul 2019 11:12:40 +0200 Subject: [PATCH] properly fix the QueryReturnedNoRows warning and rustfmt --- src/dc_chat.rs | 20 ++++++++++---------- src/dc_receive_imf.rs | 4 +--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/dc_chat.rs b/src/dc_chat.rs index b698d6526..daf05e5e5 100644 --- a/src/dc_chat.rs +++ b/src/dc_chat.rs @@ -152,6 +152,16 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool { ); match res { + Err(crate::error::Error::Sql(rusqlite::Error::QueryReturnedNoRows)) => false, + Err(err) => match err { + _ => { + error!( + context, + 0, "chat: failed to load from db {}: {:?}", chat_id, err + ); + false + } + }, Ok(_) => { let c = unsafe { &mut *chat }; match c.id { @@ -184,16 +194,6 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool { } true } - Err(err) => match err { - QueryReturnedNoRows => false, - _ => { - error!( - context, - 0, "chat: failed to load from db {}: {:?}", chat_id, err - ); - false - } - }, } } diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 5f40146db..f59aaaf08 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -515,9 +515,7 @@ pub unsafe fn dc_receive_imf( (*part).bytes, hidden, if 0 != save_mime_headers { - let body_string = unsafe { - std::str::from_utf8(std::slice::from_raw_parts(imf_raw_not_terminated as *const u8, imf_raw_bytes)).unwrap() - }; + let body_string = std::str::from_utf8(std::slice::from_raw_parts(imf_raw_not_terminated as *const u8, imf_raw_bytes)).unwrap(); Some(body_string) } else {