style: Add an Atom::from_addrefed function.

This commit is contained in:
Cameron McCormack 2017-04-05 16:54:51 +08:00
parent 1071c3339f
commit f3dcef8c81

View file

@ -198,6 +198,16 @@ impl Atom {
"Called from_static for a non-static atom!");
atom
}
/// Creates an atom from a dynamic atom pointer that has already had AddRef
/// called on it.
#[inline]
pub unsafe fn from_addrefed(ptr: *mut nsIAtom) -> Self {
debug_assert!(!ptr.is_null());
unsafe {
Atom(WeakAtom::new(ptr))
}
}
}
impl Hash for Atom {