Generalise RootedVec::<JS<T>>::r as [JS<T>]::r

This commit is contained in:
Anthony Ramine 2016-05-13 14:32:52 +02:00
parent 45c9aa7487
commit 3a547cc113
2 changed files with 8 additions and 9 deletions

View file

@ -461,6 +461,13 @@ pub trait RootedReference<'root> {
fn r(&'root self) -> Self::Ref;
}
impl<'root, T: JSTraceable + Reflectable + 'root> RootedReference<'root> for [JS<T>] {
type Ref = &'root [&'root T];
fn r(&'root self) -> &'root [&'root T] {
unsafe { mem::transmute(self) }
}
}
impl<'root, T: Reflectable + 'root> RootedReference<'root> for Rc<T> {
type Ref = &'root T;
fn r(&'root self) -> &'root T {