servo_arc cleanups for publishing.

Differential Revision: https://phabricator.services.mozilla.com/D6034
This commit is contained in:
Manish Goregaokar 2018-09-18 09:19:18 +00:00 committed by Emilio Cobos Álvarez
parent 22da3c22a2
commit 84ca681a78
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 229 additions and 154 deletions

View file

@ -8,18 +8,22 @@
use attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use matching::{ElementSelectorFlags, MatchingContext};
use parser::SelectorImpl;
use servo_arc::NonZeroPtrMut;
use std::fmt::Debug;
use std::ptr::NonNull;
/// Opaque representation of an Element, for identity comparisons. We use
/// NonZeroPtrMut to get the NonZero optimization.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct OpaqueElement(NonZeroPtrMut<()>);
pub struct OpaqueElement(NonNull<()>);
unsafe impl Send for OpaqueElement {}
impl OpaqueElement {
/// Creates a new OpaqueElement from an arbitrarily-typed pointer.
pub fn new<T>(ptr: *const T) -> Self {
OpaqueElement(NonZeroPtrMut::new(ptr as *const () as *mut ()))
pub fn new<T>(ptr: &T) -> Self {
unsafe {
OpaqueElement(NonNull::new_unchecked(ptr as *const T as *const () as *mut ()))
}
}
}