Make WeakRuleNode::from_ptr be unsafe

This commit is contained in:
Anthony Ramine 2020-04-16 14:39:14 +02:00
parent 05accaa7bd
commit e06e164571

View file

@ -369,7 +369,7 @@ impl StrongRuleNode {
} }
pub(super) fn downgrade(&self) -> WeakRuleNode { 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. /// Get the parent rule node of this rule node.
@ -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 { impl WeakRuleNode {
#[inline] #[inline]
fn ptr(&self) -> *mut RuleNode { fn ptr(&self) -> *mut RuleNode {
@ -770,7 +764,7 @@ impl WeakRuleNode {
unsafe { StrongRuleNode::from_ptr(self.p) } 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 } WeakRuleNode { p }
} }
} }