Skip to content

Commit

Permalink
Matched: add boxed_clone() method
Browse files Browse the repository at this point in the history
We may need to clone a Matches instance but it's impossible without
putting it behind a pointer (object safety).

Signed-off-by: Tibor Benke <tibor.benke@balabit.com>
  • Loading branch information
Tibor Benke committed Jul 23, 2015
1 parent 7574759 commit 7ca8cb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/matcher/matcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pub mod builder;
pub trait Matcher: fmt::Debug {
fn parse<'a, 'b>(&'a self, text: &'b str) -> Option<MatchResult<'a, 'b>>;
fn add_pattern(&mut self, pattern: Pattern);
fn boxed_clone(&self) -> Box<Matcher>;
}
3 changes: 3 additions & 0 deletions src/matcher/trie/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ impl Matcher for ParserTrie {
fn add_pattern(&mut self, pattern: Pattern) {
self.insert(pattern);
}
fn boxed_clone(&self) -> Box<Matcher> {
Box::new(self.clone())
}
}

0 comments on commit 7ca8cb8

Please sign in to comment.