refactor: rename Substitutor.matcher_type to matcher

This commit is contained in:
Harsh Shandilya 2022-02-20 13:50:55 +05:30
parent 6c4b5f617b
commit 80e33e97e6
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
3 changed files with 4 additions and 4 deletions

View file

@ -14,7 +14,7 @@ pub struct Substitutor<'config> {
#[serde(default)] #[serde(default)]
pub name: &'config str, pub name: &'config str,
#[serde(borrow, alias = "matcher")] #[serde(borrow, alias = "matcher")]
pub matcher_type: MatcherType<'config>, pub matcher: MatcherType<'config>,
#[serde(borrow)] #[serde(borrow)]
pub action: Action<'config>, pub action: Action<'config>,
} }

View file

@ -58,7 +58,7 @@ fn loop_clipboard<'a>(config: Replacements<'a>) {
let mut clipboard_contents = get_clipboard_contents(&mut clipboard); let mut clipboard_contents = get_clipboard_contents(&mut clipboard);
while let Ok(contents) = clipboard_contents.as_deref() { while let Ok(contents) = clipboard_contents.as_deref() {
if let Some(subst) = config.substitutors.iter().find(|subst| { if let Some(subst) = config.substitutors.iter().find(|subst| {
return match &subst.matcher_type { return match &subst.matcher {
MatcherType::Single(matcher) => matcher.check_match(contents), MatcherType::Single(matcher) => matcher.check_match(contents),
MatcherType::Multiple(matchers) => { MatcherType::Multiple(matchers) => {
matchers.iter().all(|matcher| matcher.check_match(contents)) matchers.iter().all(|matcher| matcher.check_match(contents))

View file

@ -52,7 +52,7 @@ fn parse_with_multiple_matchers() {
assert_eq!(1, config.substitutors.len()); assert_eq!(1, config.substitutors.len());
let subst = &config.substitutors[0]; let subst = &config.substitutors[0];
assert_eq!("Example", subst.name); assert_eq!("Example", subst.name);
assert!(matches!(subst.matcher_type, MatcherType::Multiple(_))); assert!(matches!(subst.matcher, MatcherType::Multiple(_)));
assert!(matches!(subst.action, Action::Prefix { .. })); assert!(matches!(subst.action, Action::Prefix { .. }));
} }
@ -68,6 +68,6 @@ fn parse_with_single_matcher() {
assert_eq!(1, config.substitutors.len()); assert_eq!(1, config.substitutors.len());
let subst = &config.substitutors[0]; let subst = &config.substitutors[0];
assert_eq!("Example", subst.name); assert_eq!("Example", subst.name);
assert!(matches!(subst.matcher_type, MatcherType::Single(_))); assert!(matches!(subst.matcher, MatcherType::Single(_)));
assert!(matches!(subst.action, Action::Prefix { .. })); assert!(matches!(subst.action, Action::Prefix { .. }));
} }