pub struct HandleScope<'m> { /* private fields */ }Expand description
A region in which native code can root values across calls back into the interpreter (which may collect). Handles borrow the scope, so the borrow checker keeps them from escaping it; dropping the scope releases them.
ⓘ
let scope = HandleScope::new(&mut vm.m);
let list = scope.root(make_list(scope.mutator()));
vm_call_that_may_collect();
let still_valid = scope.get(list);Implementations§
Source§impl<'m> HandleScope<'m>
impl<'m> HandleScope<'m>
pub fn new(m: &'m mut Mutator) -> Self
Sourcepub unsafe fn detached(m: *mut Mutator) -> HandleScope<'static>
pub unsafe fn detached(m: *mut Mutator) -> HandleScope<'static>
A scope that does not borrow the mutator, so native code can keep calling into the VM while it holds handles. Handles still cannot outlive the scope.
§Safety
m must outlive the scope and belong to the current thread.
pub fn get(&self, h: Local<'_>) -> Value
pub fn set(&self, h: Local<'_>, v: Value)
Trait Implementations§
Source§impl Drop for HandleScope<'_>
impl Drop for HandleScope<'_>
Auto Trait Implementations§
impl<'m> !RefUnwindSafe for HandleScope<'m>
impl<'m> !Send for HandleScope<'m>
impl<'m> !Sync for HandleScope<'m>
impl<'m> !UnwindSafe for HandleScope<'m>
impl<'m> Freeze for HandleScope<'m>
impl<'m> Unpin for HandleScope<'m>
impl<'m> UnsafeUnpin for HandleScope<'m>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more