Globs can sometimes know how deep they will have to traverse. * will never have to go deeper than one level, and */*/* will never have to go deeper than three.
You can't predict how deep a tree wildcard ** can go, so you have to bail out on any heuristic that encounters it. Same goes for repetitions.
Such a heuristic could probably make a definite prediction on maximum depth for patterns that don't include any of these, but the important thing would to never underestimate how many segments a pattern may match. So it would probably be smart to only apply it when the user hasn't provided a WalkBehavior.depth. Unfortunately, it's not an Option, so maybe you'd have to compare it to usize::MAX, or change WalkBehavior and introduce a breaking change.
Is this a reasonable thing to expect from the library? I would like for it to be in this library and not in, say, nym, if implemented.
Globs can sometimes know how deep they will have to traverse.
*
will never have to go deeper than one level, and*/*/*
will never have to go deeper than three.You can't predict how deep a tree wildcard
**
can go, so you have to bail out on any heuristic that encounters it. Same goes for repetitions.Such a heuristic could probably make a definite prediction on maximum depth for patterns that don't include any of these, but the important thing would to never underestimate how many segments a pattern may match. So it would probably be smart to only apply it when the user hasn't provided a
WalkBehavior.depth
. Unfortunately, it's not anOption
, so maybe you'd have to compare it tousize::MAX
, or change WalkBehavior and introduce a breaking change.Is this a reasonable thing to expect from the library? I would like for it to be in this library and not in, say,
nym
, if implemented.