Skip to content

Commit

Permalink
servo_arc cleanups for publishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth authored and emilio committed Sep 18, 2018
1 parent 22da3c2 commit 84ca681
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 154 deletions.
12 changes: 8 additions & 4 deletions components/selectors/tree.rs
Expand Up @@ -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 ()))
}
}
}

Expand Down

0 comments on commit 84ca681

Please sign in to comment.