Skip to content

Commit 4fd1835

Browse files
committed
Add an as_mut method to MutableHandle
Signed-off-by: Greg Morenz <[email protected]>
1 parent f040d4a commit 4fd1835

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mozjs/src/gc/root.rs

+5
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ impl<'a, T> MutableHandle<'a, T> {
216216
unsafe { *self.ptr = v }
217217
}
218218

219+
/// Safety: GC must not run during the lifetime of the returned reference.
220+
pub unsafe fn as_mut<'b: 'a>(&mut self) -> &'b mut T {
221+
&mut *(self.ptr)
222+
}
223+
219224
/// Creates a copy of this object, with a shorter lifetime, that holds a
220225
/// mutable borrow on the original object. When you write code that wants
221226
/// to use a `MutableHandle` more than once, you will typically need to

0 commit comments

Comments
 (0)