regex: make match_string() receiver immutable

This commit is contained in:
Alexander Medvednikov 2022-12-10 13:03:31 +03:00
parent 7c4f45a375
commit 42a9eaac0e

View File

@ -124,7 +124,8 @@ pub fn (re RE) get_group_list() []Re_group {
******************************************************************************/
// match_string Match the pattern with the in_txt string
[direct_array_access]
pub fn (mut re RE) match_string(in_txt string) (int, int) {
pub fn (re &RE) match_string(in_txt string) (int, int) {
unsafe {
start, mut end := re.match_base(in_txt.str, in_txt.len + 1)
if end > in_txt.len {
end = in_txt.len
@ -144,9 +145,10 @@ pub fn (mut re RE) match_string(in_txt string) (int, int) {
}
return start, end
}
}
// matches_string Checks if the pattern matches the in_txt string
pub fn (mut re RE) matches_string(in_txt string) bool {
pub fn (re &RE) matches_string(in_txt string) bool {
start, _ := re.match_string(in_txt)
return start != no_match_found
}