1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2024-12-02 02:56:32 +02:00

globset: add GlobSet::builder

This avoids needing to import and call GlobSetBuilder::new explicitly.

Closes #2635
This commit is contained in:
Jonas Platte 2023-10-16 23:55:22 +02:00 committed by Andrew Gallant
parent 922bad2b92
commit 824778c009

View File

@ -304,6 +304,14 @@ pub struct GlobSet {
} }
impl 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. /// Create an empty `GlobSet`. An empty set matches nothing.
#[inline] #[inline]
pub fn empty() -> GlobSet { pub fn empty() -> GlobSet {
@ -485,9 +493,9 @@ pub struct GlobSetBuilder {
} }
impl 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 /// 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 { pub fn new() -> GlobSetBuilder {
GlobSetBuilder { pats: vec![] } GlobSetBuilder { pats: vec![] }
} }