diff --git a/src/conversions.rs b/src/conversions.rs index c04a37c07..193b0be9b 100644 --- a/src/conversions.rs +++ b/src/conversions.rs @@ -27,6 +27,7 @@ #![deny(missing_docs)] +use core::nonzero::NonZero; use error::throw_type_error; use glue::RUST_JS_NumberValue; use jsapi::JSPROP_ENUMERATE; @@ -619,3 +620,12 @@ impl ToJSValConvertible for *mut JSObject { assert!(JS_WrapValue(cx, rval)); } } + +// https://heycam.github.io/webidl/#es-object +impl ToJSValConvertible for NonZero<*mut JSObject> { + #[inline] + unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandleValue) { + rval.set(ObjectValue(&***self)); + assert!(JS_WrapValue(cx, rval)); + } +} diff --git a/src/lib.rs b/src/lib.rs index 5bc9edb3a..24f6c798b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,13 +5,13 @@ #![crate_name = "js"] #![crate_type = "rlib"] -#![feature(filling_drop)] #![feature(link_args)] +#![feature(nonzero)] #![feature(const_fn)] -#![allow(drop_with_repr_extern)] #![allow(non_upper_case_globals, non_camel_case_types, non_snake_case, improper_ctypes)] +extern crate core; #[macro_use] extern crate heapsize; #[macro_use]