fix(modulo): fix warnings

This commit is contained in:
Federico Terzi 2021-10-05 22:07:04 +02:00
parent 8ecee79aa7
commit 16350123d2
5 changed files with 8 additions and 20 deletions

View File

@ -114,7 +114,7 @@ fn command_filter(
)
};
let results = search_algorithm(trimmed_query, &items);
let results = search_algorithm(trimmed_query, items);
results
.into_iter()

View File

@ -156,11 +156,7 @@ mod interop {
impl From<types::Field> for OwnedField {
fn from(field: types::Field) -> Self {
let id = if let Some(id) = field.id {
Some(CString::new(id).expect("unable to create cstring for field id"))
} else {
None
};
let id = field.id.map(|id| CString::new(id).expect("unable to create cstring for field id"));
let field_type = match field.field_type {
types::FieldType::Row(_) => FieldType_ROW,

View File

@ -68,12 +68,8 @@ mod interop {
impl From<&ErrorSet> for OwnedErrorSet {
fn from(error_set: &ErrorSet) -> Self {
let file_path = if let Some(file_path) = &error_set.file {
Some(CString::new(file_path.to_string_lossy().to_string())
.expect("unable to convert file_path to CString"))
} else {
None
};
let file_path = error_set.file.as_ref().map(|file_path| CString::new(file_path.to_string_lossy().to_string())
.expect("unable to convert file_path to CString"));
let errors: Vec<OwnedErrorMetadata> =
error_set.errors.iter().map(|item| item.into()).collect();
@ -136,7 +132,7 @@ pub fn show(options: TroubleshootingOptions) -> Result<()> {
.expect("unable to acquire lock in dont_show_again_changed method");
let handlers_ref = (*lock).as_ref().expect("unable to unwrap handlers");
if let Some(handler_ref) = handlers_ref.dont_show_again_changed.as_ref() {
let value = if dont_show == 1 { true } else { false };
let value = dont_show == 1;
(*handler_ref)(value);
}
}

View File

@ -39,7 +39,7 @@ pub fn show(options: WelcomeOptions) {
.expect("unable to acquire lock in dont_show_again_changed method");
let handlers_ref = (*lock).as_ref().expect("unable to unwrap handlers");
if let Some(handler_ref) = handlers_ref.dont_show_again_changed.as_ref() {
let value = if dont_show == 1 { true } else { false };
let value = dont_show == 1;
(*handler_ref)(value);
}
}

View File

@ -17,7 +17,7 @@
* along with modulo. If not, see <https://www.gnu.org/licenses/>.
*/
use std::os::raw::{c_char, c_int};
use std::os::raw::{c_int};
use std::{ffi::CString, sync::Mutex};
use crate::sys::interop::{
@ -200,9 +200,5 @@ pub fn show(options: WizardOptions) -> bool {
let successful = unsafe { super::interop::interop_show_wizard(&wizard_metadata) };
if successful == 1 {
true
} else {
false
}
successful == 1
}