fn score_window<H: Handle>(&self, window: &Window<H>) -> u8 {
        // returns true if any of the items in the provided `Vec<&Option<String>>` is Some and matches the `&Regex`
        let matches_any = |re: &Regex, strs: Vec<&Option<String>>| {
            strs.iter().any(|str| {
                str.as_ref().is_some_and(|s| {
                    // we match the class/title to the window rule by checking if replacing the text
                    // with the regex makes the string empty. if the original string is already
                    // empty, this will match it to every regex, so we need to check for that.
                    // however, if the window rule is explicitly for empty strings, we still
                    // want empty strings to match to it.
                    re.replace(s, "").is_empty() && (!s.is_empty() || re.as_str().is_empty())
                })
            })
        };

        let class_score = self.window_class.as_ref().map_or(0, |re| {
            u8::from(matches_any(re, vec![&window.res_class, &window.res_name]))
        });

        let title_score = self.window_title.as_ref().map_or(0, |re| {
            u8::from(matches_any(re, vec![&window.legacy_name, &window.name]))
        });

        class_score + 2 * title_score
    }
Score the similarity between a [`leftwm_core::models::Window`] and a [`WindowHook`].

Multiple [`WindowHook`]s might match a `WM_CLASS` but we want the most
specific one to apply: matches by title are scored greater than by `WM_CLASS`.
leftwm/src/config.rs