mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
servo_arc cleanups for publishing.
Differential Revision: https://phabricator.services.mozilla.com/D6034
This commit is contained in:
parent
22da3c22a2
commit
84ca681a78
4 changed files with 229 additions and 154 deletions
|
@ -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 ()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue