cleaner code
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m34s

This commit is contained in:
philipp 2024-02-06 14:18:03 +01:00
parent b39666a72d
commit 6d428be193
3 changed files with 10 additions and 13 deletions

View File

@ -1,12 +1,13 @@
use serde::Deserialize; #[allow(clippy::wildcard_imports)] // I use *-operator on purpose: I want to receive a compiler
use std::fs; // warning if I've not updated my `create_classifier` function
use std::path::Path;
use std::sync::Arc;
use crate::law::{self, responsible::*}; use crate::law::{self, responsible::*};
use crate::law::{ClassifierApplicable, LawBuilder}; use crate::law::{ClassifierApplicable, LawBuilder};
use crate::misc::Error; use crate::misc::Error;
use crate::paragraph::Parser; use crate::paragraph::Parser;
use serde::Deserialize;
use std::fs;
use std::path::Path;
use std::sync::Arc;
// TODO: more generic // TODO: more generic
fn create_classifier(match_function: &str) -> Result<ClassifierApplicable, Error> { fn create_classifier(match_function: &str) -> Result<ClassifierApplicable, Error> {
@ -22,8 +23,7 @@ fn create_classifier(match_function: &str) -> Result<ClassifierApplicable, Error
"contains_without_unter" => Arc::new(contains_without_unter), "contains_without_unter" => Arc::new(contains_without_unter),
_ => { _ => {
return Err(Error::new(&format!( return Err(Error::new(&format!(
"Unknown match function: {}", "Unknown match function: {match_function}"
match_function
))) )))
} }
}; };

View File

@ -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 { 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 { pub fn starts_with_roman_number(_: &str, s: &str) -> bool {

View File

@ -89,12 +89,9 @@ fn fetch(url: &str) -> Result<String, Error> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::fs;
use std::{fs}; use crate::config::Config;
use crate::{
config::Config,
};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
#[test] #[test]