Skip to main content

boa_engine/
try_into_js_result_impls.rs

1//! Declare implementations of [`TryIntoJsResult`] trait for various types.
2
3use crate::value::TryIntoJs;
4use crate::{Context, JsResult, JsValue, TryIntoJsResult};
5
6impl<T> TryIntoJsResult for T
7where
8    T: TryIntoJs,
9{
10    fn try_into_js_result(self, ctx: &mut Context) -> JsResult<JsValue> {
11        self.try_into_js(ctx)
12    }
13}
14
15impl<T> TryIntoJsResult for JsResult<T>
16where
17    T: TryIntoJsResult,
18{
19    fn try_into_js_result(self, cx: &mut Context) -> JsResult<JsValue> {
20        self.and_then(|value| value.try_into_js_result(cx))
21    }
22}