comparison rust/hg-core/src/filepatterns.rs @ 51470:406b413e3cf2 stable

rust-filepatterns: export glob_to_re function Making this function public should not risk freezing the internal API, and it can be useful for all downstream code that needs to perform glob matching against byte strings, such as RHGitaly where it will be useful to match on branches and tags.
author Georges Racinet <georges.racinet@octobus.net>
date Mon, 11 Mar 2024 13:23:18 +0100
parents 532e74ad3ff6
children 2a89d2f6336f
comparison
equal deleted inserted replaced
51467:68ed56baabf5 51470:406b413e3cf2
71 /// Note: `Box` is used to minimize size impact on other enum variants 71 /// Note: `Box` is used to minimize size impact on other enum variants
72 ExpandedSubInclude(Box<SubInclude>), 72 ExpandedSubInclude(Box<SubInclude>),
73 } 73 }
74 74
75 /// Transforms a glob pattern into a regex 75 /// Transforms a glob pattern into a regex
76 fn glob_to_re(pat: &[u8]) -> Vec<u8> { 76 pub fn glob_to_re(pat: &[u8]) -> Vec<u8> {
77 let mut input = pat; 77 let mut input = pat;
78 let mut res: Vec<u8> = vec![]; 78 let mut res: Vec<u8> = vec![];
79 let mut group_depth = 0; 79 let mut group_depth = 0;
80 80
81 while let Some((c, rest)) = input.split_first() { 81 while let Some((c, rest)) = input.split_first() {