1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-06-20 06:15:37 +02:00

globset: expand docs and impl Default for GlobSet

Closes #1882, Closes #1883
This commit is contained in:
Martin Pool
2021-05-31 15:54:55 -07:00
committed by Andrew Gallant
parent ee23ab5173
commit 8a4071eea9
2 changed files with 17 additions and 1 deletions

View File

@ -616,6 +616,8 @@ impl<'a> GlobBuilder<'a> {
}
/// Toggle whether a literal `/` is required to match a path separator.
///
/// By default this is false: `*` and `?` will match `/`.
pub fn literal_separator(&mut self, yes: bool) -> &mut GlobBuilder<'a> {
self.opts.literal_separator = yes;
self

View File

@ -456,6 +456,13 @@ impl GlobSet {
}
}
impl Default for GlobSet {
/// Create a default empty GlobSet.
fn default() -> Self {
GlobSet::empty()
}
}
/// GlobSetBuilder builds a group of patterns that can be used to
/// simultaneously match a file path.
#[derive(Clone, Debug)]
@ -833,7 +840,7 @@ impl RequiredExtensionStrategyBuilder {
#[cfg(test)]
mod tests {
use super::GlobSetBuilder;
use super::{GlobSet, GlobSetBuilder};
use glob::Glob;
#[test]
@ -863,4 +870,11 @@ mod tests {
assert!(!set.is_match(""));
assert!(!set.is_match("a"));
}
#[test]
fn default_set_is_empty_works() {
let set: GlobSet = Default::default();
assert!(!set.is_match(""));
assert!(!set.is_match("a"));
}
}