Skip to content

Commit

Permalink
Further lint fixing that was missed in the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FriederHannenheim committed Jan 24, 2024
1 parent 2e84e75 commit e5555c1
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/ui/slint_types.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -59,14 +59,14 @@ macro_rules! properties_check {
}

impl $enum_name {
pub fn check_propreties(existing_properties: &Vec<SlintProperty>) -> 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 {
Expand Down Expand Up @@ -111,14 +111,14 @@ macro_rules! callbacks_check {
}

impl $enum_name {
pub fn check_callbacks(existing_callbacks: &Vec<String>) -> 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 {
Expand All @@ -143,4 +143,5 @@ macro_rules! callbacks_check {
callbacks_check!(
RequiredCallbacks,
Submit -> "submit"
);
);

0 comments on commit e5555c1

Please sign in to comment.