diff --git a/mozjs-sys/src/jsimpls.rs b/mozjs-sys/src/jsimpls.rs index 21caf59f8eb..ca49b85f21f 100644 --- a/mozjs-sys/src/jsimpls.rs +++ b/mozjs-sys/src/jsimpls.rs @@ -27,7 +27,6 @@ use crate::jsval::{JSVal, UndefinedValue}; use std::marker::PhantomData; use std::mem; use std::ops::Deref; -use std::ops::DerefMut; use std::ptr; impl Deref for JS::Handle { @@ -46,12 +45,6 @@ impl Deref for JS::MutableHandle { } } -impl DerefMut for JS::MutableHandle { - fn deref_mut<'a>(&'a mut self) -> &'a mut T { - unsafe { &mut *self.ptr } - } -} - impl Default for jsid { fn default() -> Self { VoidId() @@ -119,6 +112,13 @@ impl JS::MutableHandle { { unsafe { *self.ptr = v } } + + /// The returned pointer is aliased by a pointer that the GC will read + /// through, and thus `&mut` references created from it must not be held + /// across GC pauses. + pub fn as_ptr(self) -> *mut T { + self.ptr + } } impl JS::HandleValue {