checker: extend byte deprecation warnings to return types (#19668)

This commit is contained in:
Turiiya 2023-10-29 13:25:15 +01:00 committed by GitHub
parent e86abe0376
commit 1e578b1144
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View file

@ -1735,15 +1735,13 @@ pub fn (s string) str() string {
// at returns the byte at index `idx`.
// Example: assert 'ABC'.at(1) == u8(`B`)
fn (s string) at(idx int) byte {
fn (s string) at(idx int) u8 {
$if !no_bounds_checking {
if idx < 0 || idx >= s.len {
panic('string index out of range: ${idx} / ${s.len}')
}
}
unsafe {
return s.str[idx]
}
return unsafe { s.str[idx] }
}
// version of `at()` that is used in `a[i] or {`