Use then/then_some to simplify.

This commit is contained in:
Stephen Chung
2023-02-21 16:36:57 +08:00
parent 00f2b07d38
commit 129a5c6e86
6 changed files with 31 additions and 63 deletions

View File

@@ -139,12 +139,8 @@ impl Engine {
// Built-in found
auto_restore! { let orig_level = global.level; global.level += 1 }
let context = if need_context {
let source = global.source();
Some((self, op_x_str, source, &*global, pos).into())
} else {
None
};
let context = need_context
.then_some((self, op_x_str, global.source(), &*global, pos).into());
return func(context, args).map(|_| ());
}
}