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:
committed by
Andrew Gallant
parent
ee23ab5173
commit
8a4071eea9
@ -616,6 +616,8 @@ impl<'a> GlobBuilder<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Toggle whether a literal `/` is required to match a path separator.
|
/// 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> {
|
pub fn literal_separator(&mut self, yes: bool) -> &mut GlobBuilder<'a> {
|
||||||
self.opts.literal_separator = yes;
|
self.opts.literal_separator = yes;
|
||||||
self
|
self
|
||||||
|
@ -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
|
/// GlobSetBuilder builds a group of patterns that can be used to
|
||||||
/// simultaneously match a file path.
|
/// simultaneously match a file path.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -833,7 +840,7 @@ impl RequiredExtensionStrategyBuilder {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::GlobSetBuilder;
|
use super::{GlobSet, GlobSetBuilder};
|
||||||
use glob::Glob;
|
use glob::Glob;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -863,4 +870,11 @@ mod tests {
|
|||||||
assert!(!set.is_match(""));
|
assert!(!set.is_match(""));
|
||||||
assert!(!set.is_match("a"));
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user