Skip to content

Commit ee6450e

Browse files
committed
issue-1224 Change to map_err instead of match
1 parent 190e617 commit ee6450e

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

vm/src/obj/objstr.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,25 +1230,20 @@ fn do_cformat_specifier(
12301230
}
12311231
Ok(format_spec.format_number(objint::get_value(&obj)))
12321232
}
1233-
CFormatType::Float(_) => {
1234-
let result = if objtype::isinstance(&obj, &vm.ctx.float_type()) {
1235-
format_spec.format_float(objfloat::get_value(&obj))
1236-
} else if objtype::isinstance(&obj, &vm.ctx.int_type()) {
1237-
format_spec.format_float(objint::get_value(&obj).to_f64().unwrap())
1238-
} else {
1239-
let required_type_string = "an floating point or integer";
1240-
return Err(vm.new_type_error(format!(
1241-
"%{} format: {} is required, not {}",
1242-
format_spec.format_char,
1243-
required_type_string,
1244-
obj.class()
1245-
)));
1246-
};
1247-
match result {
1248-
Ok(transformed) => Ok(transformed),
1249-
Err(error) => Err(vm.new_not_implemented_error(error)),
1250-
}
1233+
CFormatType::Float(_) => if objtype::isinstance(&obj, &vm.ctx.float_type()) {
1234+
format_spec.format_float(objfloat::get_value(&obj))
1235+
} else if objtype::isinstance(&obj, &vm.ctx.int_type()) {
1236+
format_spec.format_float(objint::get_value(&obj).to_f64().unwrap())
1237+
} else {
1238+
let required_type_string = "an floating point or integer";
1239+
return Err(vm.new_type_error(format!(
1240+
"%{} format: {} is required, not {}",
1241+
format_spec.format_char,
1242+
required_type_string,
1243+
obj.class()
1244+
)));
12511245
}
1246+
.map_err(|e| vm.new_not_implemented_error(e)),
12521247
CFormatType::Character => {
12531248
let char_string = {
12541249
if objtype::isinstance(&obj, &vm.ctx.int_type()) {

0 commit comments

Comments
 (0)