[oden-js] Convert Option<>

This commit is contained in:
John Doty 2023-06-23 05:48:26 -07:00
parent af12dccd5d
commit c7903382a0
2 changed files with 21 additions and 0 deletions

View file

@ -128,3 +128,13 @@ impl<T: Class> TryIntoValue for T {
self.into_value(ctx)
}
}
impl<T: TryIntoValue> TryIntoValue for Option<T> {
#[inline]
fn try_into_value(self, ctx: &ContextRef) -> ValueResult {
match self {
None => Ok(ctx.undefined()),
Some(v) => v.try_into_value(ctx),
}
}
}