Skip to content

Commit

Permalink
Make WeakRuleNode::from_ptr be unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Apr 17, 2020
1 parent 05accaa commit e06e164
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions components/style/rule_tree/core.rs
Expand Up @@ -369,7 +369,7 @@ impl StrongRuleNode {
}

pub(super) fn downgrade(&self) -> WeakRuleNode {
WeakRuleNode::from_ptr(self.p)
unsafe { WeakRuleNode::from_ptr(self.p) }
}

/// Get the parent rule node of this rule node.
Expand Down Expand Up @@ -750,12 +750,6 @@ impl Drop for StrongRuleNode {
}
}

impl<'a> From<&'a StrongRuleNode> for WeakRuleNode {
fn from(node: &'a StrongRuleNode) -> Self {
WeakRuleNode::from_ptr(node.p)
}
}

impl WeakRuleNode {
#[inline]
fn ptr(&self) -> *mut RuleNode {
Expand All @@ -770,7 +764,7 @@ impl WeakRuleNode {
unsafe { StrongRuleNode::from_ptr(self.p) }
}

fn from_ptr(p: ptr::NonNull<RuleNode>) -> Self {
unsafe fn from_ptr(p: ptr::NonNull<RuleNode>) -> Self {
WeakRuleNode { p }
}
}

0 comments on commit e06e164

Please sign in to comment.