Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

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

  • Loading branch information
nox committed May 16, 2016
commit a66957e7f72f204e6bb9bb4a7f2513183695a815
@@ -456,6 +456,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: RootedReference<'root> + 'root> RootedReference<'root> for Option<T> {
type Ref = Option<T::Ref>;
fn r(&'root self) -> Option<T::Ref> {
@@ -34,7 +34,7 @@ use canvas_traits::{CompositionOrBlending, LineCapStyle, LineJoinStyle, Repetiti
use cssparser::RGBA;
use devtools_traits::CSSError;
use devtools_traits::WorkerId;
use dom::bindings::js::{JS, Root, RootedReference};
use dom::bindings::js::{JS, Root};
use dom::bindings::refcounted::Trusted;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::bindings::utils::WindowProxyHandler;
@@ -75,7 +75,6 @@ use std::collections::{BTreeMap, HashMap, HashSet};
use std::hash::{BuildHasher, Hash};
use std::intrinsics::return_address;
use std::iter::{FromIterator, IntoIterator};
use std::mem;
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use std::sync::Arc;
@@ -509,13 +508,6 @@ impl<T: JSTraceable> RootedVec<T> {
}
}

impl<'root, T: JSTraceable + Reflectable + 'root> RootedReference<'root> for RootedVec<JS<T>> {
type Ref = &'root [&'root T];
fn r(&'root self) -> &'root [&'root T] {
unsafe { mem::transmute(&self.v[..]) }
}
}

impl<T: JSTraceable> Drop for RootedVec<T> {
fn drop(&mut self) {
unsafe {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.