Replace unwrap with expect.

This commit is contained in:
Stephen Chung
2021-05-22 19:14:24 +08:00
parent 1545b602a7
commit cc3e2d79a5
18 changed files with 600 additions and 323 deletions

View File

@@ -27,9 +27,9 @@ pub fn print_with_func(
value: &mut Dynamic,
) -> crate::ImmutableString {
match ctx.call_fn_dynamic_raw(fn_name, true, &mut [value]) {
Ok(result) if result.is::<crate::ImmutableString>() => {
result.take_immutable_string().unwrap()
}
Ok(result) if result.is::<crate::ImmutableString>() => result
.take_immutable_string()
.expect("never fails as the result is `ImmutableString`"),
Ok(result) => ctx.engine().map_type_name(result.type_name()).into(),
Err(_) => ctx.engine().map_type_name(value.type_name()).into(),
}