Mark the CoordData traits as unsafe

This commit is contained in:
Manish Goregaokar 2017-08-28 08:07:57 -07:00
parent 94c870726f
commit 799437430e

View file

@ -20,7 +20,7 @@ impl nsStyleCoord {
} }
} }
impl CoordData for nsStyleCoord { unsafe impl CoordData for nsStyleCoord {
#[inline] #[inline]
fn unit(&self) -> nsStyleUnit { fn unit(&self) -> nsStyleUnit {
unsafe { unsafe {
@ -35,7 +35,7 @@ impl CoordData for nsStyleCoord {
} }
} }
impl CoordDataMut for nsStyleCoord { unsafe impl CoordDataMut for nsStyleCoord {
unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) { unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
let unit = self.get_mUnit_mut() as *mut _; let unit = self.get_mUnit_mut() as *mut _;
let value = self.get_mValue_mut() as *mut _; let value = self.get_mValue_mut() as *mut _;
@ -98,7 +98,7 @@ pub struct SidesDataMut<'a> {
index: usize, index: usize,
} }
impl<'a> CoordData for SidesData<'a> { unsafe impl<'a> CoordData for SidesData<'a> {
#[inline] #[inline]
fn unit(&self) -> nsStyleUnit { fn unit(&self) -> nsStyleUnit {
unsafe { unsafe {
@ -112,7 +112,7 @@ impl<'a> CoordData for SidesData<'a> {
} }
} }
} }
impl<'a> CoordData for SidesDataMut<'a> { unsafe impl<'a> CoordData for SidesDataMut<'a> {
#[inline] #[inline]
fn unit(&self) -> nsStyleUnit { fn unit(&self) -> nsStyleUnit {
unsafe { unsafe {
@ -126,7 +126,7 @@ impl<'a> CoordData for SidesDataMut<'a> {
} }
} }
} }
impl<'a> CoordDataMut for SidesDataMut<'a> { unsafe impl<'a> CoordDataMut for SidesDataMut<'a> {
unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) { unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
let unit = &mut self.sides.get_mUnits_mut()[self.index] as *mut _; let unit = &mut self.sides.get_mUnits_mut()[self.index] as *mut _;
let value = &mut self.sides.get_mValues_mut()[self.index] as *mut _; let value = &mut self.sides.get_mValues_mut()[self.index] as *mut _;
@ -168,7 +168,7 @@ pub struct CornersDataMut<'a> {
index: usize, index: usize,
} }
impl<'a> CoordData for CornersData<'a> { unsafe impl<'a> CoordData for CornersData<'a> {
fn unit(&self) -> nsStyleUnit { fn unit(&self) -> nsStyleUnit {
unsafe { unsafe {
self.corners.get_mUnits()[self.index] self.corners.get_mUnits()[self.index]
@ -180,7 +180,7 @@ impl<'a> CoordData for CornersData<'a> {
} }
} }
} }
impl<'a> CoordData for CornersDataMut<'a> { unsafe impl<'a> CoordData for CornersDataMut<'a> {
fn unit(&self) -> nsStyleUnit { fn unit(&self) -> nsStyleUnit {
unsafe { unsafe {
self.corners.get_mUnits()[self.index] self.corners.get_mUnits()[self.index]
@ -192,7 +192,7 @@ impl<'a> CoordData for CornersDataMut<'a> {
} }
} }
} }
impl<'a> CoordDataMut for CornersDataMut<'a> { unsafe impl<'a> CoordDataMut for CornersDataMut<'a> {
unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) { unsafe fn values_mut(&mut self) -> (&mut nsStyleUnit, &mut nsStyleUnion) {
let unit = &mut self.corners.get_mUnits_mut()[self.index] as *mut _; let unit = &mut self.corners.get_mUnits_mut()[self.index] as *mut _;
let value = &mut self.corners.get_mValues_mut()[self.index] as *mut _; let value = &mut self.corners.get_mValues_mut()[self.index] as *mut _;
@ -240,7 +240,7 @@ pub enum CoordDataValue {
/// A trait to abstract on top of a mutable `nsStyleCoord`-like object. /// A trait to abstract on top of a mutable `nsStyleCoord`-like object.
pub trait CoordDataMut : CoordData { pub unsafe trait CoordDataMut : CoordData {
/// Get mutably the unit and the union. /// Get mutably the unit and the union.
/// ///
/// This is unsafe since it's possible to modify the unit without changing /// This is unsafe since it's possible to modify the unit without changing
@ -394,7 +394,7 @@ pub trait CoordDataMut : CoordData {
} }
} }
/// A trait to abstract on top of a `nsStyleCoord`-like object. /// A trait to abstract on top of a `nsStyleCoord`-like object.
pub trait CoordData { pub unsafe trait CoordData {
/// Get the unit of this object. /// Get the unit of this object.
fn unit(&self) -> nsStyleUnit; fn unit(&self) -> nsStyleUnit;
/// Get the `nsStyleUnion` for this object. /// Get the `nsStyleUnion` for this object.