From 6d428be193be7da7dfc9ae9bfa996d52bce13d61 Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 6 Feb 2024 14:18:03 +0100 Subject: [PATCH] cleaner code --- src/config.rs | 14 +++++++------- src/law/responsible.rs | 2 +- src/paragraph/mod.rs | 7 ++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/config.rs b/src/config.rs index 951c61d..62e8f1e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,12 +1,13 @@ -use serde::Deserialize; -use std::fs; -use std::path::Path; -use std::sync::Arc; - +#[allow(clippy::wildcard_imports)] // I use *-operator on purpose: I want to receive a compiler +// warning if I've not updated my `create_classifier` function use crate::law::{self, responsible::*}; use crate::law::{ClassifierApplicable, LawBuilder}; use crate::misc::Error; use crate::paragraph::Parser; +use serde::Deserialize; +use std::fs; +use std::path::Path; +use std::sync::Arc; // TODO: more generic fn create_classifier(match_function: &str) -> Result { @@ -22,8 +23,7 @@ fn create_classifier(match_function: &str) -> Result Arc::new(contains_without_unter), _ => { return Err(Error::new(&format!( - "Unknown match function: {}", - match_function + "Unknown match function: {match_function}" ))) } }; diff --git a/src/law/responsible.rs b/src/law/responsible.rs index c3a8279..a2b9e04 100644 --- a/src/law/responsible.rs +++ b/src/law/responsible.rs @@ -12,7 +12,7 @@ pub fn contains(classifier_name: &str, instance_name: &str) -> bool { } pub fn contains_case_sensitive(classifier_name: &str, instance_name: &str) -> bool { - instance_name.contains(&classifier_name) + instance_name.contains(classifier_name) } pub fn starts_with_roman_number(_: &str, s: &str) -> bool { diff --git a/src/paragraph/mod.rs b/src/paragraph/mod.rs index 656651c..f15580c 100644 --- a/src/paragraph/mod.rs +++ b/src/paragraph/mod.rs @@ -89,12 +89,9 @@ fn fetch(url: &str) -> Result { #[cfg(test)] mod tests { + use std::fs; - use std::{fs}; - - use crate::{ - config::Config, - }; + use crate::config::Config; use pretty_assertions::assert_eq; #[test]