fix example

This commit is contained in:
ge 2025-01-13 20:54:32 +03:00
parent 8dc59e114c
commit f4fe18ed49

View File

@ -18,8 +18,8 @@ fn (m Memory) mib() f64 {
fn Memory.from_string(s string) !Memory { fn Memory.from_string(s string) !Memory {
mut re := regex.regex_opt(r'^(\d+)([a-zA-Z]+)$')! mut re := regex.regex_opt(r'^(\d+)([a-zA-Z]+)$')!
re.match_string(s) re.match_string(s)
if re.groups.len < 2 { if re.groups.len != 2 {
return error('unable to parse string ${s}') return error("unable to parse string '${s}'")
} }
value := re.get_group_by_id(s, 0).f64() value := re.get_group_by_id(s, 0).f64()
unit := dataunits.from_string(re.get_group_by_id(s, 1))! unit := dataunits.from_string(re.get_group_by_id(s, 1))!