Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

Commit 437460d

Browse files
author
bors-servo
authored
Auto merge of #492 - Manishearth:tojsval, r=jdm
Add ToJSValConvertible impls for &T and Box<T> This lets us do things like write a `to_frozen_array()` function that operates on `&[impl ToJSValConvertible]`, agnostic about `&T`, `DomRoot<T>`, or `&Dom<T>` r? @jdm
2 parents 9b0d063 + 240a078 commit 437460d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/conversions.rs

+14
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,20 @@ impl<T: ToJSValConvertible> ToJSValConvertible for Option<T> {
513513
}
514514
}
515515

516+
impl<T: ToJSValConvertible> ToJSValConvertible for &'_ T {
517+
#[inline]
518+
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
519+
(**self).to_jsval(cx, rval)
520+
}
521+
}
522+
523+
impl<T: ToJSValConvertible> ToJSValConvertible for Box<T> {
524+
#[inline]
525+
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {
526+
(**self).to_jsval(cx, rval)
527+
}
528+
}
529+
516530
impl<T: ToJSValConvertible> ToJSValConvertible for Rc<T> {
517531
#[inline]
518532
unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) {

0 commit comments

Comments
 (0)