mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix_replace
This commit is contained in:
parent
b6b313d246
commit
b0bc53730c
@ -75,7 +75,7 @@ pub fn (s string) cstr() byteptr {
|
||||
|
||||
pub fn (s string) replace(rep, with string) string {
|
||||
if s.len == 0 || rep.len == 0 {
|
||||
return ''
|
||||
return s
|
||||
}
|
||||
if !s.contains(rep) {
|
||||
return s
|
||||
|
@ -165,6 +165,8 @@ fn test_replace() {
|
||||
assert b.replace('B', '') == 'onetwothree'
|
||||
b = '**char'
|
||||
assert b.replace('*char', 'byteptr') == '*byteptr'
|
||||
mut c :='abc'
|
||||
assert c.replace('','-') == c
|
||||
}
|
||||
|
||||
fn test_itoa() {
|
||||
|
Loading…
Reference in New Issue
Block a user