1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

string: make index() return ?int instead of int/-1

This commit is contained in:
Alexander Medvednikov
2019-11-30 13:09:05 +03:00
parent cc2bd0bb68
commit 81d4f66fbb
11 changed files with 117 additions and 103 deletions

View File

@@ -931,8 +931,8 @@ fn (p &Parser) identify_typo(name string) string {
// compare just name part, some items are mod prefied
fn typo_compare_name_mod(a, b, b_mod string) f32 {
if a.len - b.len > 2 || b.len - a.len > 2 { return 0 }
auidx := a.index('__')
buidx := b.index('__')
auidx := a.index('__') or { -1 }
buidx := b.index('__') or { -1 }
a_mod := if auidx != -1 { mod_gen_name_rev(a[..auidx]) } else { '' }
a_name := if auidx != -1 { a[auidx+2..] } else { a }
b_name := if buidx != -1 { b[buidx+2..] } else { b }