1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-01-19 05:49:14 +02:00

globset: clarify documentation on regex method

This makes it clear that the `bytes` API of the regex crate should be
used instead of the Unicode API.

Fixes #985
This commit is contained in:
Andrew Gallant 2018-07-21 13:23:46 -04:00
parent 7b6af5a177
commit d09e2f6af1
No known key found for this signature in database
GPG Key ID: B2E3A4923F8B0D44

View File

@ -275,6 +275,19 @@ impl Glob {
} }
/// Returns the regular expression string for this glob. /// Returns the regular expression string for this glob.
///
/// Note that regular expressions for globs are intended to be matched on
/// arbitrary bytes (`&[u8]`) instead of Unicode strings (`&str`). In
/// particular, globs are frequently used on file paths, where there is no
/// general guarantee that file paths are themselves valid UTF-8. As a
/// result, callers will need to ensure that they are using a regex API
/// that can match on arbitrary bytes. For example, the
/// [`regex`](https://crates.io/regex)
/// crate's
/// [`Regex`](https://docs.rs/regex/*/regex/struct.Regex.html)
/// API is not suitable for this since it matches on `&str`, but its
/// [`bytes::Regex`](https://docs.rs/regex/*/regex/bytes/struct.Regex.html)
/// API is suitable for this.
pub fn regex(&self) -> &str { pub fn regex(&self) -> &str {
&self.re &self.re
} }