mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove useless unsafe methods on JS<T>
This commit is contained in:
parent
1389be3782
commit
9369b616ce
2 changed files with 7 additions and 35 deletions
|
@ -5453,7 +5453,7 @@ impl ${name}Cast {
|
|||
#[inline(always)]
|
||||
pub fn to_ref<'a, T: ${toBound}+Reflectable>(base: JSRef<'a, T>) -> Option<JSRef<'a, ${name}>> {
|
||||
match base.${checkFn}() {
|
||||
true => unsafe { Some(base.transmute()) },
|
||||
true => Some(unsafe { mem::transmute(base) }),
|
||||
false => None
|
||||
}
|
||||
}
|
||||
|
@ -5461,7 +5461,7 @@ impl ${name}Cast {
|
|||
#[inline(always)]
|
||||
pub fn to_borrowed_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a JSRef<'b, T>) -> Option<&'a JSRef<'b, ${name}>> {
|
||||
match base.${checkFn}() {
|
||||
true => unsafe { Some(base.transmute_borrowed()) },
|
||||
true => Some(unsafe { mem::transmute(base) }),
|
||||
false => None
|
||||
}
|
||||
}
|
||||
|
@ -5479,22 +5479,20 @@ impl ${name}Cast {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn to_temporary<T: ${toBound}+Reflectable>(base: Temporary<T>) -> Option<Temporary<${name}>> {
|
||||
let base = base.root();
|
||||
let base = base.r();
|
||||
match base.${checkFn}() {
|
||||
true => Some(Temporary::from_rooted(unsafe { base.transmute() })),
|
||||
match base.root().r().${checkFn}() {
|
||||
true => Some(unsafe { mem::transmute(base) }),
|
||||
false => None
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn from_ref<'a, T: ${fromBound}+Reflectable>(derived: JSRef<'a, T>) -> JSRef<'a, ${name}> {
|
||||
unsafe { derived.transmute() }
|
||||
unsafe { mem::transmute(derived) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn from_borrowed_ref<'a, 'b, T: ${fromBound}+Reflectable>(derived: &'a JSRef<'b, T>) -> &'a JSRef<'b, ${name}> {
|
||||
unsafe { derived.transmute_borrowed() }
|
||||
unsafe { mem::transmute(derived) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -5505,7 +5503,7 @@ impl ${name}Cast {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn from_temporary<T: ${fromBound}+Reflectable>(derived: Temporary<T>) -> Temporary<${name}> {
|
||||
unsafe { derived.transmute() }
|
||||
unsafe { mem::transmute(derived) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
|
@ -186,13 +186,6 @@ impl<T: Reflectable> Temporary<T> {
|
|||
unsafe fn inner(&self) -> JS<T> {
|
||||
self.inner.clone()
|
||||
}
|
||||
|
||||
/// Returns `self` as a `Temporary` of another type. For use by
|
||||
/// `InheritTypes` only.
|
||||
//XXXjdm It would be lovely if this could be private.
|
||||
pub unsafe fn transmute<To>(self) -> Temporary<To> {
|
||||
mem::transmute(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// A traced reference to a DOM object. Must only be used as a field in other
|
||||
|
@ -438,13 +431,6 @@ impl<T: Reflectable> LayoutJS<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<From> JS<From> {
|
||||
/// Return `self` as a `JS` of another type.
|
||||
pub unsafe fn transmute_copy<To>(&self) -> JS<To> {
|
||||
mem::transmute_copy(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<From> LayoutJS<From> {
|
||||
/// Return `self` as a `LayoutJS` of another type.
|
||||
pub unsafe fn transmute_copy<To>(&self) -> LayoutJS<To> {
|
||||
|
@ -748,18 +734,6 @@ impl<'a, 'b, T> PartialEq<JSRef<'b, T>> for JSRef<'a, T> {
|
|||
}
|
||||
|
||||
impl<'a,T> JSRef<'a,T> {
|
||||
/// Return `self` as a `JSRef` of another type.
|
||||
//XXXjdm It would be lovely if this could be private.
|
||||
pub unsafe fn transmute<To>(self) -> JSRef<'a, To> {
|
||||
mem::transmute(self)
|
||||
}
|
||||
|
||||
/// Return `self` as a borrowed reference to a `JSRef` of another type.
|
||||
// FIXME(zwarich): It would be nice to get rid of this entirely.
|
||||
pub unsafe fn transmute_borrowed<'b, To>(&'b self) -> &'b JSRef<'a, To> {
|
||||
mem::transmute(self)
|
||||
}
|
||||
|
||||
/// Return an unrooted `JS<T>` for the inner pointer.
|
||||
pub fn unrooted(&self) -> JS<T> {
|
||||
JS {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue