File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,29 @@ pub trait FromJSValConvertible: Sized {
167
167
) -> Result < ConversionResult < Self > , ( ) > ;
168
168
}
169
169
170
+ /// A trait to convert `JSVal`s to Rust types inside of Rc wrappers.
171
+ pub trait FromJSValConvertibleRc : Sized {
172
+ /// Convert `val` to type `Self`.
173
+ /// If it returns `Err(())`, a JSAPI exception is pending.
174
+ /// If it returns `Ok(Failure(reason))`, there is no pending JSAPI exception.
175
+ unsafe fn from_jsval (
176
+ cx : * mut JSContext ,
177
+ val : HandleValue ,
178
+ ) -> Result < ConversionResult < Rc < Self > > , ( ) > ;
179
+ }
180
+
181
+ impl < T : FromJSValConvertibleRc > FromJSValConvertible for Rc < T > {
182
+ type Config = ( ) ;
183
+
184
+ unsafe fn from_jsval (
185
+ cx : * mut JSContext ,
186
+ val : HandleValue ,
187
+ _option : ( ) ,
188
+ ) -> Result < ConversionResult < Rc < T > > , ( ) > {
189
+ <T as FromJSValConvertibleRc >:: from_jsval ( cx, val)
190
+ }
191
+ }
192
+
170
193
/// Behavior for converting out-of-range integers.
171
194
#[ derive( PartialEq , Eq , Clone ) ]
172
195
pub enum ConversionBehavior {
You can’t perform that action at this time.
0 commit comments