Skip to content

Commit

Permalink
Implement Clone for Matchers and export them
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years committed Apr 11, 2024
1 parent 521c121 commit 0bba8ac
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test-harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ mod matcher;
pub use matcher::BaseMatcher;
pub use matcher::IntoMatcher;
pub use matcher::Matcher;
pub use matcher::NegativeMatcher;
pub use matcher::NeverMatcher;
pub use matcher::OptionMatcher;
pub use matcher::OrMatcher;
pub use matcher::SpanMatcher;
Expand Down
1 change: 1 addition & 0 deletions test-harness/src/matcher/and_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::Event;
use crate::Matcher;

/// A [`Matcher`] that can match either of two other matchers.
#[derive(Clone)]
pub struct AndMatcher<A, B>(pub A, pub B);

impl<A, B> Display for AndMatcher<A, B>
Expand Down
1 change: 1 addition & 0 deletions test-harness/src/matcher/fused_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::Matcher;

/// Wraps another [`Matcher`] and stops calling [`Matcher::matches`] on it after it first returns
/// `true`.
#[derive(Clone)]
pub struct FusedMatcher<M> {
inner: M,
matched: bool,
Expand Down
1 change: 1 addition & 0 deletions test-harness/src/matcher/negative_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::Matcher;

/// Wraps two matchers. The first matcher is used as normal, except if the negative matcher
/// matches an event, [`Matcher::matches`] errors.
#[derive(Clone)]
pub struct NegativeMatcher<M, N> {
inner: M,
negative: N,
Expand Down
1 change: 1 addition & 0 deletions test-harness/src/matcher/never_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt::Display;
use crate::Matcher;

/// A matcher that never matches.
#[derive(Clone)]
pub struct NeverMatcher;

impl Display for NeverMatcher {
Expand Down
1 change: 1 addition & 0 deletions test-harness/src/matcher/option_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use super::NeverMatcher;
/// A matcher which may or may not contain a matcher.
///
/// If it does not contain a matcher, it never matches.
#[derive(Clone)]
pub struct OptionMatcher<M>(Option<M>);

impl OptionMatcher<NeverMatcher> {
Expand Down
1 change: 1 addition & 0 deletions test-harness/src/matcher/or_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::Event;
use crate::Matcher;

/// A [`Matcher`] that can match either of two other matchers.
#[derive(Clone)]
pub struct OrMatcher<A, B>(pub A, pub B);

impl<A, B> Display for OrMatcher<A, B>
Expand Down

0 comments on commit 0bba8ac

Please sign in to comment.