mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
builtin: str.last_index(); pref: hide-auto-str;
This commit is contained in:
parent
85533fe178
commit
acf0107493
13 changed files with 82 additions and 49 deletions
|
@ -750,7 +750,14 @@ fn (s string) index_last_(p string) int {
|
|||
}
|
||||
|
||||
// index_last returns the position of the first character of the *last* occurrence of the `needle` string in `s`.
|
||||
@[deprecated: 'use `.last_index(needle string)` instead']
|
||||
pub fn (s string) index_last(needle string) ?int {
|
||||
return s.last_index(needle)
|
||||
}
|
||||
|
||||
// last_index returns the position of the first character of the *last* occurrence of the `needle` string in `s`.
|
||||
@[inline]
|
||||
pub fn (s string) last_index(needle string) ?int {
|
||||
idx := s.index_last_(needle)
|
||||
if idx == -1 {
|
||||
return none
|
||||
|
@ -758,14 +765,6 @@ pub fn (s string) index_last(needle string) ?int {
|
|||
return idx
|
||||
}
|
||||
|
||||
// last_index returns the position of the first character of the *last* occurrence of the `needle` string in `s`.
|
||||
@[deprecated: 'use `.index_last(needle string)` instead']
|
||||
@[deprecated_after: '2023-12-18']
|
||||
@[inline]
|
||||
pub fn (s string) last_index(needle string) ?int {
|
||||
return s.index_last(needle)
|
||||
}
|
||||
|
||||
pub fn (s string) trim_space() string {
|
||||
res := ''
|
||||
#res.str = s.str.trim()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue