globset: make GlobSet::new public
For users of globset who already have a `Vec<Glob>` (or similar), the current API requires them to iterate over their `Vec<Glob>`, calling `GlobSetBuilder::add` for each `Glob`, thus constructing a new `Vec<Glob>` internal to the GlobSetBuilder. This makes the consuming code unnecessarily verbose. (There is unlikely to be any meaningful performance impact of this, however, since the cost of allocating a new `Vec` is likely marginal compared to the cost of glob compilation.) Instead of taking a `&[Glob]`, we accept an iterator of anything that can be borrowed as a `&Glob`. This required some light refactoring of the constructor, but nothing onerous. Closes #3066
This commit is contained in:
committed by
Andrew Gallant
parent
33b44812c0
commit
859d54270e
@@ -80,6 +80,12 @@ pub struct Glob {
|
||||
tokens: Tokens,
|
||||
}
|
||||
|
||||
impl AsRef<Glob> for Glob {
|
||||
fn as_ref(&self) -> &Glob {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Glob {
|
||||
fn eq(&self, other: &Glob) -> bool {
|
||||
self.glob == other.glob && self.opts == other.opts
|
||||
|
||||
Reference in New Issue
Block a user