mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Introduce RootedVec<JS<T>>::r()
This commit is contained in:
parent
658c3d05ae
commit
389a9ff643
4 changed files with 24 additions and 20 deletions
|
@ -70,6 +70,7 @@ use std::collections::hash_state::HashState;
|
|||
use std::ffi::CString;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::intrinsics::return_address;
|
||||
use std::mem;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
@ -482,6 +483,13 @@ impl<T: JSTraceable + Reflectable> RootedVec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: JSTraceable + Reflectable> RootedVec<JS<T>> {
|
||||
/// Obtain a safe slice of references that can't outlive that RootedVec.
|
||||
pub fn r(&self) -> &[&T] {
|
||||
unsafe { mem::transmute(&*self.v) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: JSTraceable + Reflectable> Drop for RootedVec<T> {
|
||||
fn drop(&mut self) {
|
||||
RootedTraceableSet::remove(self);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue