clean code with clippy
All checks were successful
CI/CD Pipeline / test (push) Successful in 37s

This commit is contained in:
2024-02-04 21:46:38 +01:00
parent ab21651a87
commit 32533a2d17
5 changed files with 34 additions and 8 deletions

View File

@ -168,7 +168,7 @@ impl LawBuilder {
}
/// Creates a new law builder. Adds classifier for known law texts.
pub(crate) fn new(name: &str) -> Law {
pub(crate) fn new(name: &str) -> Self {
let mut classifiers = Vec::new();
let mut law_id = None;
@ -288,7 +288,7 @@ impl LawBuilder {
let responsible_class = self
.responsible_classifier(name)
.expect(&format!("No classifier for '{name}'"));
.unwrap_or_else(|| panic!("No classifier for '{name}'"));
let mut heading: ClassifierInstance = name.into();
@ -457,10 +457,12 @@ impl From<&str> for ClassifierInstance {
}
}
type ClassifierApplicable = Arc<dyn Fn(&str, &str) -> bool>;
#[derive(Clone)]
pub(crate) struct Classifier {
pub(crate) name: String, // Hauptstück, Theil, Abschnitt, ol
pub(crate) used_for_fn: Arc<dyn Fn(&str, &str) -> bool>,
pub(crate) used_for_fn: ClassifierApplicable,
pub(crate) instances: Vec<ClassifierInstance>,
pub(crate) child: Vec<Rc<RefCell<Classifier>>>,
pub(crate) root: bool,
@ -473,7 +475,7 @@ impl PartialEq for Classifier {
}
impl Classifier {
fn new(name: &str, used_for_fn: Arc<dyn Fn(&str, &str) -> bool>) -> Self {
fn new(name: &str, used_for_fn: ClassifierApplicable) -> Self {
Self {
name: name.into(),
used_for_fn,
@ -554,7 +556,7 @@ mod tests {
#[ignore]
#[test]
fn test_with_live_data() {
let law = LawBuilder::new("UrhG");
let law: Law = LawBuilder::new("UrhG").into();
let path = Path::new("./data/urhg/builder.result");
let mut file = File::open(path).unwrap();
@ -569,7 +571,7 @@ mod tests {
#[ignore]
#[test]
fn test_stgb_with_live_data() {
let law = LawBuilder::new("StGB");
let law: Law = LawBuilder::new("StGB").into();
let path = Path::new("./data/stgb/builder.result");
let mut file = File::open(path).unwrap();