From e5555c184a4a75ba0161f09b9a47f08622da350a Mon Sep 17 00:00:00 2001 From: FriederHannenheim Date: Wed, 24 Jan 2024 22:36:51 +0100 Subject: [PATCH] Further lint fixing that was missed in the previous commit --- src/ui/slint_types.rs | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/ui/slint_types.rs b/src/ui/slint_types.rs index fcf31b0..3ac8aba 100644 --- a/src/ui/slint_types.rs +++ b/src/ui/slint_types.rs @@ -1,11 +1,8 @@ -use std::{ - fmt::Display, - ops::Deref, -}; +use std::{fmt::Display, ops::Deref}; use slint_interpreter::ValueType; -use crate::{Result, common::CthulockError}; +use crate::{common::CthulockError, Result}; #[derive(PartialEq, Clone)] pub struct SlintProperty { @@ -17,15 +14,19 @@ impl SlintProperty { pub fn new(name: &str, value_type: ValueType) -> Self { Self { name: name.to_owned(), - value_type + value_type, } } } impl Display for SlintProperty { -fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "Property '{}' of type '{:?}'", self.name, self.value_type) -} + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!( + f, + "Property '{}' of type '{:?}'", + self.name, self.value_type + ) + } } impl From<(&str, ValueType)> for SlintProperty { @@ -41,12 +42,11 @@ impl From<(String, ValueType)> for SlintProperty { fn from(value: (String, ValueType)) -> Self { Self { name: value.0, - value_type: value.1 + value_type: value.1, } } } - macro_rules! properties_check { ( $enum_name:ident, @@ -59,14 +59,14 @@ macro_rules! properties_check { } impl $enum_name { - pub fn check_propreties(existing_properties: &Vec) -> Result<()> { + pub fn check_propreties(existing_properties: &[SlintProperty]) -> Result<()> { let property_options = vec![$(SlintProperty::new($property_name, $property_type),)+]; let missing_properties: Vec<_> = property_options .iter() .filter(|value| !existing_properties.contains(value)) .map(ToString::to_string) .collect(); - + if missing_properties.is_empty() { Ok(()) } else { @@ -111,14 +111,14 @@ macro_rules! callbacks_check { } impl $enum_name { - pub fn check_callbacks(existing_callbacks: &Vec) -> Result<()> { + pub fn check_callbacks(existing_callbacks: &[String]) -> Result<()> { let callback_options = vec![$($callback_name.to_string(),)+]; let missing_callbacks: Vec<_> = callback_options .iter() .filter(|value| !existing_callbacks.contains(value)) .map(ToString::to_string) .collect(); - + if missing_callbacks.is_empty() { Ok(()) } else { @@ -143,4 +143,5 @@ macro_rules! callbacks_check { callbacks_check!( RequiredCallbacks, Submit -> "submit" -); \ No newline at end of file +); +