Skip to content

Commit

Permalink
Move SkipRegex impls to the toplevel.
Browse files Browse the repository at this point in the history
This triggers a lint (at least on nightly) which
will become deny-by-default in the next edition:
<rust-lang/rust#120363>
  • Loading branch information
thomcc authored and nvzqz committed May 25, 2024
1 parent 8768032 commit 9ae8153
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/divan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,26 @@ pub trait SkipRegex {
fn skip_regex(self, divan: &mut Divan);
}

impl SkipRegex for Regex {
fn skip_regex(self, divan: &mut Divan) {
divan.skip_filters.push(Filter::Regex(self));
}
}

impl SkipRegex for &str {
#[track_caller]
fn skip_regex(self, divan: &mut Divan) {
Regex::new(self).unwrap().skip_regex(divan);
}
}

impl SkipRegex for String {
#[track_caller]
fn skip_regex(self, divan: &mut Divan) {
self.as_str().skip_regex(divan)
}
}

/// Configuration options.
impl Divan {
/// Creates an instance with options set by parsing CLI arguments.
Expand Down Expand Up @@ -552,26 +572,6 @@ impl Divan {
/// Panics if `filter` is a string and [`Regex::new`] fails.
#[must_use]
pub fn skip_regex(mut self, filter: impl SkipRegex) -> Self {
impl SkipRegex for Regex {
fn skip_regex(self, divan: &mut Divan) {
divan.skip_filters.push(Filter::Regex(self));
}
}

impl SkipRegex for &str {
#[track_caller]
fn skip_regex(self, divan: &mut Divan) {
Regex::new(self).unwrap().skip_regex(divan);
}
}

impl SkipRegex for String {
#[track_caller]
fn skip_regex(self, divan: &mut Divan) {
self.as_str().skip_regex(divan)
}
}

filter.skip_regex(&mut self);
self
}
Expand Down

0 comments on commit 9ae8153

Please sign in to comment.