Skip to content

Commit

Permalink
impl Default for RegexSet
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Sep 21, 2022
1 parent 159a63c commit 1b08a56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/re_set.rs
Expand Up @@ -289,6 +289,12 @@ impl RegexSet {
}
}

impl Default for RegexSet {
fn default() -> Self {
RegexSet::empty()
}
}

/// A set of matches returned by a regex set.
#[derive(Clone, Debug)]
pub struct SetMatches {
Expand Down
7 changes: 7 additions & 0 deletions tests/set.rs
Expand Up @@ -65,3 +65,10 @@ fn len_and_empty() {
assert_eq!(not_empty.len(), 2);
assert!(!not_empty.is_empty());
}

#[test]
fn default_set_is_empty() {
let set: regex::bytes::RegexSet = Default::default();
assert_eq!(set.len(), 0);
assert!(set.is_empty());
}

0 comments on commit 1b08a56

Please sign in to comment.