replace to_i() with int() everywhere
parent
c84318bf6b
commit
48d65d6881
|
@ -138,16 +138,12 @@ pub fn (s string) replace(rep, with string) string {
|
||||||
return tos(b, new_len)
|
return tos(b, new_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s string) to_i() int {
|
fn (s string) int() int {
|
||||||
return C.atoi(s.str)
|
return C.atoi(s.str)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (s string) int() int {
|
fn (s string) f32() f32 {
|
||||||
return s.to_i()
|
return C.atof(s.str)
|
||||||
}
|
|
||||||
|
|
||||||
fn (s string) i32() int {
|
|
||||||
return s.to_i()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==
|
// ==
|
||||||
|
|
|
@ -251,16 +251,16 @@ fn test_arr_contains() {
|
||||||
|
|
||||||
fn test_to_num() {
|
fn test_to_num() {
|
||||||
s := '7'
|
s := '7'
|
||||||
assert s.to_i() == 7
|
assert s.int() == 7
|
||||||
f := '71.5 hasdf'
|
f := '71.5 hasdf'
|
||||||
assert f.to_float() == 71.5
|
assert f.f32() == 71.5
|
||||||
b := 1.52345
|
b := 1.52345
|
||||||
mut a := '${b:.03f}'
|
mut a := '${b:.03f}'
|
||||||
assert a == '1.523'
|
assert a == '1.523'
|
||||||
num := 7
|
num := 7
|
||||||
a = '${num:03d}'
|
a = '${num:03d}'
|
||||||
vals := ['9']
|
vals := ['9']
|
||||||
assert vals[0].to_i() == 9
|
assert vals[0].int() == 9
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_hash() {
|
fn test_hash() {
|
||||||
|
@ -289,4 +289,4 @@ fn test_all_after() {
|
||||||
s := 'fn hello'
|
s := 'fn hello'
|
||||||
q := s.all_after('fn ')
|
q := s.all_after('fn ')
|
||||||
assert q == 'hello'
|
assert q == 'hello'
|
||||||
}
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ fn (req &Request) do() Response {
|
||||||
mut status_code := 0
|
mut status_code := 0
|
||||||
if first_header.contains('HTTP/') {
|
if first_header.contains('HTTP/') {
|
||||||
val := first_header.find_between(' ', ' ')
|
val := first_header.find_between(' ', ' ')
|
||||||
status_code = val.to_i()
|
status_code = val.int()
|
||||||
}
|
}
|
||||||
// Build resp headers map
|
// Build resp headers map
|
||||||
// println('building resp headers hchunk.strings.len')
|
// println('building resp headers hchunk.strings.len')
|
||||||
|
|
12
time/time.v
12
time/time.v
|
@ -260,12 +260,12 @@ pub fn parse(s string) Time {
|
||||||
second := hms[2]
|
second := hms[2]
|
||||||
// //////////
|
// //////////
|
||||||
return new_time(Time {
|
return new_time(Time {
|
||||||
year: ymd[0].to_i()
|
year: ymd[0].int()
|
||||||
month: ymd[1].to_i()
|
month: ymd[1].int()
|
||||||
day: ymd[2].to_i()
|
day: ymd[2].int()
|
||||||
hour: hour.to_i()
|
hour: hour.int()
|
||||||
minute: minute.to_i()
|
minute: minute.int()
|
||||||
second: second.to_i()
|
second: second.int()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue