mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Merge pull request #3633 from korvahkh/fix-slice-has-affix
Fix slice.has_prefix & slice.has_suffix
This commit is contained in:
@@ -222,7 +222,7 @@ prefix_length :: proc(a, b: $T/[]$E) -> (n: int) where intrinsics.type_is_compar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@(require_results)
|
@(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)
|
n := len(needle)
|
||||||
if len(array) >= n {
|
if len(array) >= n {
|
||||||
return equal(array[:n], needle)
|
return equal(array[:n], needle)
|
||||||
@@ -232,7 +232,7 @@ has_prefix :: proc(array: $T/[]$E, needle: E) -> bool where intrinsics.type_is_c
|
|||||||
|
|
||||||
|
|
||||||
@(require_results)
|
@(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
|
array := array
|
||||||
m, n := len(array), len(needle)
|
m, n := len(array), len(needle)
|
||||||
if m >= n {
|
if m >= n {
|
||||||
|
|||||||
Reference in New Issue
Block a user