replace to_i() with int() everywhere

pull/556/head
Alexander Medvednikov 2019-06-25 14:56:34 +02:00
parent c84318bf6b
commit 48d65d6881
4 changed files with 14 additions and 18 deletions

View File

@ -138,16 +138,12 @@ pub fn (s string) replace(rep, with string) string {
return tos(b, new_len)
}
fn (s string) to_i() int {
fn (s string) int() int {
return C.atoi(s.str)
}
fn (s string) int() int {
return s.to_i()
}
fn (s string) i32() int {
return s.to_i()
fn (s string) f32() f32 {
return C.atof(s.str)
}
// ==

View File

@ -251,16 +251,16 @@ fn test_arr_contains() {
fn test_to_num() {
s := '7'
assert s.to_i() == 7
assert s.int() == 7
f := '71.5 hasdf'
assert f.to_float() == 71.5
assert f.f32() == 71.5
b := 1.52345
mut a := '${b:.03f}'
assert a == '1.523'
num := 7
a = '${num:03d}'
vals := ['9']
assert vals[0].to_i() == 9
assert vals[0].int() == 9
}
fn test_hash() {
@ -289,4 +289,4 @@ fn test_all_after() {
s := 'fn hello'
q := s.all_after('fn ')
assert q == 'hello'
}

View File

@ -156,7 +156,7 @@ fn (req &Request) do() Response {
mut status_code := 0
if first_header.contains('HTTP/') {
val := first_header.find_between(' ', ' ')
status_code = val.to_i()
status_code = val.int()
}
// Build resp headers map
// println('building resp headers hchunk.strings.len')

View File

@ -260,12 +260,12 @@ pub fn parse(s string) Time {
second := hms[2]
// //////////
return new_time(Time {
year: ymd[0].to_i()
month: ymd[1].to_i()
day: ymd[2].to_i()
hour: hour.to_i()
minute: minute.to_i()
second: second.to_i()
year: ymd[0].int()
month: ymd[1].int()
day: ymd[2].int()
hour: hour.int()
minute: minute.int()
second: second.int()
})
}