Skip to content

Commit

Permalink
Merge pull request #3633 from korvahkh/fix-slice-has-affix
Browse files Browse the repository at this point in the history
Fix slice.has_prefix & slice.has_suffix
  • Loading branch information
gingerBill committed May 25, 2024
2 parents cfadca0 + 58ae96c commit ef7a155
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/slice/slice.odin
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ prefix_length :: proc(a, b: $T/[]$E) -> (n: int) where intrinsics.type_is_compar
}

@(require_results)
has_prefix :: proc(array: $T/[]$E, needle: E) -> bool where intrinsics.type_is_comparable(E) {
has_prefix :: proc(array: $T/[]$E, needle: T) -> bool where intrinsics.type_is_comparable(E) {
n := len(needle)
if len(array) >= n {
return equal(array[:n], needle)
Expand All @@ -232,7 +232,7 @@ has_prefix :: proc(array: $T/[]$E, needle: E) -> bool where intrinsics.type_is_c


@(require_results)
has_suffix :: proc(array: $T/[]$E, needle: E) -> bool where intrinsics.type_is_comparable(E) {
has_suffix :: proc(array: $T/[]$E, needle: T) -> bool where intrinsics.type_is_comparable(E) {
array := array
m, n := len(array), len(needle)
if m >= n {
Expand Down

0 comments on commit ef7a155

Please sign in to comment.