Make DomRoot::new unsafe

This commit is contained in:
Anthony Ramine 2017-09-26 15:38:10 +02:00
parent 3dbb97922d
commit 1ff6c4f9aa
3 changed files with 7 additions and 6 deletions

View file

@ -86,7 +86,9 @@ impl<T: WeakReferenceable> WeakRef<T> {
/// DomRoot a weak reference. Returns `None` if the object was already collected.
pub fn root(&self) -> Option<DomRoot<T>> {
unsafe { &*self.ptr.get() }.value.get().map(DomRoot::new)
unsafe { &*self.ptr.get() }.value.get().map(|ptr| unsafe {
DomRoot::from_ref(&*ptr.get())
})
}
/// Return whether the weakly-referenced object is still alive.