mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Make NotNull move its member pointer where possible.
Differential Revision: https://phabricator.services.mozilla.com/D72827
This commit is contained in:
parent
6a7c0b7e9c
commit
735fdedbe9
1 changed files with 14 additions and 0 deletions
|
@ -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<GeckoType> OwnedOrNull<GeckoType> {
|
|||
unsafe { transmute(self) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for CopyablePtr<T> {
|
||||
type Target = T;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.mPtr
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> DerefMut for CopyablePtr<T> {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
|
||||
&mut self.mPtr
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue