From 735fdedbe9928f9cbd7863b5d4f171957b3c743e Mon Sep 17 00:00:00 2001 From: Simon Giesecke Date: Tue, 5 May 2020 09:09:01 +0000 Subject: [PATCH] style: Make NotNull move its member pointer where possible. Differential Revision: https://phabricator.services.mozilla.com/D72827 --- components/style/gecko_bindings/sugar/ownership.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs index 5170b7dbc5a..0ece222a1c4 100644 --- a/components/style/gecko_bindings/sugar/ownership.rs +++ b/components/style/gecko_bindings/sugar/ownership.rs @@ -9,6 +9,7 @@ use std::marker::PhantomData; use std::mem::{forget, transmute}; use std::ops::{Deref, DerefMut}; use std::ptr; +use gecko_bindings::structs::root::mozilla::detail::CopyablePtr; /// Indicates that a given Servo type has a corresponding Gecko FFI type. pub unsafe trait HasFFI: Sized + 'static { @@ -332,3 +333,16 @@ impl OwnedOrNull { unsafe { transmute(self) } } } + +impl Deref for CopyablePtr { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.mPtr + } +} + +impl DerefMut for CopyablePtr { + fn deref_mut<'a>(&'a mut self) -> &'a mut T { + &mut self.mPtr + } +} \ No newline at end of file