Skip to content

Commit

Permalink
globset: add GlobSet::builder
Browse files Browse the repository at this point in the history
This avoids needing to import and call GlobSetBuilder::new explicitly.

Closes #2635
  • Loading branch information
jplatte authored and BurntSushi committed Nov 21, 2023
1 parent 922bad2 commit 824778c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/globset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,14 @@ pub struct GlobSet {
}

impl GlobSet {
/// Create a new [`GlobSetBuilder`]. A `GlobSetBuilder` can be used to add
/// new patterns. Once all patterns have been added, `build` should be
/// called to produce a `GlobSet`, which can then be used for matching.
#[inline]
pub fn builder() -> GlobSetBuilder {
GlobSetBuilder::new()
}

/// Create an empty `GlobSet`. An empty set matches nothing.
#[inline]
pub fn empty() -> GlobSet {
Expand Down Expand Up @@ -485,9 +493,9 @@ pub struct GlobSetBuilder {
}

impl GlobSetBuilder {
/// Create a new GlobSetBuilder. A GlobSetBuilder can be used to add new
/// Create a new `GlobSetBuilder`. A `GlobSetBuilder` can be used to add new
/// patterns. Once all patterns have been added, `build` should be called
/// to produce a `GlobSet`, which can then be used for matching.
/// to produce a [`GlobSet`], which can then be used for matching.
pub fn new() -> GlobSetBuilder {
GlobSetBuilder { pats: vec![] }
}
Expand Down

0 comments on commit 824778c

Please sign in to comment.