Skip to content

Commit db131fc

Browse files
authored
Remove DerefMut impl for JS::MutableHandle (#574)
* Remove DerefMut impl for JS::MutableHandle Signed-off-by: Greg Morenz <[email protected]> * Add a new `JS::MutableHandle::as_mut` method Signed-off-by: Greg Morenz <[email protected]> --------- Signed-off-by: Greg Morenz <[email protected]>
1 parent 3e8e9d3 commit db131fc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mozjs-sys/src/jsimpls.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use crate::jsval::{JSVal, UndefinedValue};
2727
use std::marker::PhantomData;
2828
use std::mem;
2929
use std::ops::Deref;
30-
use std::ops::DerefMut;
3130
use std::ptr;
3231

3332
impl<T> Deref for JS::Handle<T> {
@@ -46,12 +45,6 @@ impl<T> Deref for JS::MutableHandle<T> {
4645
}
4746
}
4847

49-
impl<T> DerefMut for JS::MutableHandle<T> {
50-
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
51-
unsafe { &mut *self.ptr }
52-
}
53-
}
54-
5548
impl Default for jsid {
5649
fn default() -> Self {
5750
VoidId()
@@ -119,6 +112,13 @@ impl<T> JS::MutableHandle<T> {
119112
{
120113
unsafe { *self.ptr = v }
121114
}
115+
116+
/// The returned pointer is aliased by a pointer that the GC will read
117+
/// through, and thus `&mut` references created from it must not be held
118+
/// across GC pauses.
119+
pub fn as_ptr(self) -> *mut T {
120+
self.ptr
121+
}
122122
}
123123

124124
impl JS::HandleValue {

0 commit comments

Comments
 (0)