Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glob::partition documentation incorrectly claims that Glob outputs are always unrooted. #47

Open
olson-sean-k opened this issue Oct 6, 2023 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@olson-sean-k
Copy link
Owner

olson-sean-k commented Oct 6, 2023

At time of writing, the documentation for Glob::partition says:

Partitioned Globs are never rooted. If the glob expression has a root component, then it is always included in the invariant PathBuf prefix.

But this isn't true! There is at least one exception I'm aware of, which are expressions beginning with a rooted repetition. For example, </root:1,>.

let (path, glob) = Glob::new("</root:1,>").unwrap().partition();
assert!(glob.has_root()); // OK. `glob` has been partitioned but is still rooted!
@olson-sean-k olson-sean-k added bug Something isn't working documentation Improvements or additions to documentation labels Oct 6, 2023
@olson-sean-k
Copy link
Owner Author

Repetitions that occur at the beginning of a glob expression are the only example I can think of where this occurs. Note that rooted alternatives are forbidden at the beginning of an expression, so for example {/root} cannot occur at time of writing. However, that rule is intended to prevent overlapping trees and arguably alternatives at the beginning of an expression with only one rooting branch should be permitted.

So the documentation should be sure to mention the exception here: tree tokens (i.e., alternatives and repetitions) with roots at the beginning of an expression. Note also that when this occurs the path part is necessarily empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant