olson-sean-k / wax

Opinionated and portable globs that can be matched against paths and directory trees.
https://glob.guide
MIT License
112 stars 10 forks source link

`Glob::partition` panics if the `Glob` is empty. #46

Closed olson-sean-k closed 6 months ago

olson-sean-k commented 11 months ago

Calling Glob::partition on an empty Glob panics! This function should never panic and in this case should probably return an empty PathBuf and the empty Glob as is.

This bug raises some additional concerns that are worth pointing out. The notion of an empty glob (as with empty paths and especially empty path components) is a bit strange and annoying. Moreover, the API of Glob::partition is a victim of these empty values, because it returns (PathBuf, Glob<'_>)! There is no (sane) way for clients to determine if either part is empty.

olson-sean-k commented 6 months ago

This was fixed in 68b94ff, which completely refactored the determination of invariant text prefix and token index (where the panic previously occurred) and introduces some APIs to improve the ergonomics of empty globs. However, that change did not focus on this issue and relevant tests were not added until 2570081.