From 218bb888032c5dfe112e8f542203c1757858013e Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Wed, 28 Nov 2018 14:50:08 -0500 Subject: [PATCH] Rename DataRaw* traits to RawData* --- src/data_traits.rs | 58 +++++++++++++++++++++---------------------- src/impl_1d.rs | 2 +- src/impl_2d.rs | 2 +- src/impl_clone.rs | 6 ++--- src/impl_methods.rs | 10 ++++---- src/impl_raw_views.rs | 2 +- src/lib.rs | 12 ++++----- 7 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/data_traits.rs b/src/data_traits.rs index a685eaa2c..5dfa57316 100644 --- a/src/data_traits.rs +++ b/src/data_traits.rs @@ -27,10 +27,10 @@ use { /// does not imply any ownership or lifetime; pointers to elements in the array /// may not be safe to dereference. /// -/// ***Note:*** `DataRaw` is not an extension interface at this point. +/// ***Note:*** `RawData` is not an extension interface at this point. /// Traits in Rust can serve many different roles. This trait is public because /// it is used as a bound on public methods. -pub unsafe trait DataRaw : Sized { +pub unsafe trait RawData : Sized { /// The array element type. type Elem; @@ -45,8 +45,8 @@ pub unsafe trait DataRaw : Sized { /// /// For an array with writable elements. /// -/// ***Internal trait, see `DataRaw`.*** -pub unsafe trait DataRawMut : DataRaw { +/// ***Internal trait, see `RawData`.*** +pub unsafe trait RawDataMut : RawData { /// If possible, ensures that the array has unique access to its data. /// /// If `Self` provides safe mutable access to array elements, then it @@ -68,8 +68,8 @@ pub unsafe trait DataRawMut : DataRaw { /// /// An array representation that can be cloned. /// -/// ***Internal trait, see `DataRaw`.*** -pub unsafe trait DataRawClone : DataRaw { +/// ***Internal trait, see `RawData`.*** +pub unsafe trait RawDataClone : RawData { #[doc(hidden)] /// Unsafe because, `ptr` must point inside the current storage. unsafe fn clone_with_ptr(&self, ptr: *mut Self::Elem) -> (Self, *mut Self::Elem); @@ -86,8 +86,8 @@ pub unsafe trait DataRawClone : DataRaw { /// /// For an array with elements that can be accessed with safe code. /// -/// ***Internal trait, see `DataRaw`.*** -pub unsafe trait Data : DataRaw { +/// ***Internal trait, see `RawData`.*** +pub unsafe trait Data : RawData { /// Converts the array to a uniquely owned array, cloning elements if necessary. #[doc(hidden)] fn into_owned(self_: ArrayBase) -> ArrayBase, D> @@ -105,10 +105,10 @@ pub unsafe trait Data : DataRaw { // # For implementers // // If you implement the `DataMut` trait, you are guaranteeing that the -// `DataRawMut::try_ensure_unique` implementation always panics or ensures that +// `RawDataMut::try_ensure_unique` implementation always panics or ensures that // the data is unique. You are also guaranteeing that `try_is_unique` always // returns `Some(_)`. -pub unsafe trait DataMut : Data + DataRawMut { +pub unsafe trait DataMut : Data + RawDataMut { /// Ensures that the array has unique access to its data. #[doc(hidden)] #[inline] @@ -133,13 +133,13 @@ pub unsafe trait DataMut : Data + DataRawMut { /// accessed with safe code. /// /// ***Internal trait, see `Data`.*** -#[deprecated(note="use `Data + DataRawClone` instead", since="0.13")] -pub trait DataClone : Data + DataRawClone {} +#[deprecated(note="use `Data + RawDataClone` instead", since="0.13")] +pub trait DataClone : Data + RawDataClone {} #[allow(deprecated)] -impl DataClone for T where T: Data + DataRawClone {} +impl DataClone for T where T: Data + RawDataClone {} -unsafe impl DataRaw for RawViewRepr<*const A> { +unsafe impl RawData for RawViewRepr<*const A> { type Elem = A; fn _data_slice(&self) -> Option<&[A]> { None @@ -147,13 +147,13 @@ unsafe impl DataRaw for RawViewRepr<*const A> { private_impl!{} } -unsafe impl DataRawClone for RawViewRepr<*const A> { +unsafe impl RawDataClone for RawViewRepr<*const A> { unsafe fn clone_with_ptr(&self, ptr: *mut Self::Elem) -> (Self, *mut Self::Elem) { (*self, ptr) } } -unsafe impl DataRaw for RawViewRepr<*mut A> { +unsafe impl RawData for RawViewRepr<*mut A> { type Elem = A; fn _data_slice(&self) -> Option<&[A]> { None @@ -161,7 +161,7 @@ unsafe impl DataRaw for RawViewRepr<*mut A> { private_impl!{} } -unsafe impl DataRawMut for RawViewRepr<*mut A> { +unsafe impl RawDataMut for RawViewRepr<*mut A> { #[inline] fn try_ensure_unique(_: &mut ArrayBase) where Self: Sized, @@ -174,13 +174,13 @@ unsafe impl DataRawMut for RawViewRepr<*mut A> { } } -unsafe impl DataRawClone for RawViewRepr<*mut A> { +unsafe impl RawDataClone for RawViewRepr<*mut A> { unsafe fn clone_with_ptr(&self, ptr: *mut Self::Elem) -> (Self, *mut Self::Elem) { (*self, ptr) } } -unsafe impl DataRaw for OwnedArcRepr { +unsafe impl RawData for OwnedArcRepr { type Elem = A; fn _data_slice(&self) -> Option<&[A]> { Some(&self.0) @@ -189,7 +189,7 @@ unsafe impl DataRaw for OwnedArcRepr { } // NOTE: Copy on write -unsafe impl DataRawMut for OwnedArcRepr +unsafe impl RawDataMut for OwnedArcRepr where A: Clone, { @@ -246,14 +246,14 @@ unsafe impl Data for OwnedArcRepr { unsafe impl DataMut for OwnedArcRepr where A: Clone {} -unsafe impl DataRawClone for OwnedArcRepr { +unsafe impl RawDataClone for OwnedArcRepr { unsafe fn clone_with_ptr(&self, ptr: *mut Self::Elem) -> (Self, *mut Self::Elem) { // pointer is preserved (self.clone(), ptr) } } -unsafe impl DataRaw for OwnedRepr { +unsafe impl RawData for OwnedRepr { type Elem = A; fn _data_slice(&self) -> Option<&[A]> { Some(&self.0) @@ -261,7 +261,7 @@ unsafe impl DataRaw for OwnedRepr { private_impl!{} } -unsafe impl DataRawMut for OwnedRepr { +unsafe impl RawDataMut for OwnedRepr { #[inline] fn try_ensure_unique(_: &mut ArrayBase) where Self: Sized, @@ -287,7 +287,7 @@ unsafe impl Data for OwnedRepr { unsafe impl DataMut for OwnedRepr { } -unsafe impl DataRawClone for OwnedRepr +unsafe impl RawDataClone for OwnedRepr where A: Clone { unsafe fn clone_with_ptr(&self, ptr: *mut Self::Elem) -> (Self, *mut Self::Elem) { @@ -313,7 +313,7 @@ unsafe impl DataRawClone for OwnedRepr } } -unsafe impl<'a, A> DataRaw for ViewRepr<&'a A> { +unsafe impl<'a, A> RawData for ViewRepr<&'a A> { type Elem = A; fn _data_slice(&self) -> Option<&[A]> { None @@ -331,13 +331,13 @@ unsafe impl<'a, A> Data for ViewRepr<&'a A> { } } -unsafe impl<'a, A> DataRawClone for ViewRepr<&'a A> { +unsafe impl<'a, A> RawDataClone for ViewRepr<&'a A> { unsafe fn clone_with_ptr(&self, ptr: *mut Self::Elem) -> (Self, *mut Self::Elem) { (*self, ptr) } } -unsafe impl<'a, A> DataRaw for ViewRepr<&'a mut A> { +unsafe impl<'a, A> RawData for ViewRepr<&'a mut A> { type Elem = A; fn _data_slice(&self) -> Option<&[A]> { None @@ -345,7 +345,7 @@ unsafe impl<'a, A> DataRaw for ViewRepr<&'a mut A> { private_impl!{} } -unsafe impl<'a, A> DataRawMut for ViewRepr<&'a mut A> { +unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A> { #[inline] fn try_ensure_unique(_: &mut ArrayBase) where Self: Sized, @@ -389,7 +389,7 @@ pub unsafe trait DataOwned : Data { /// A representation that is a lightweight view. /// /// ***Internal trait, see `Data`.*** -pub unsafe trait DataShared : Clone + Data + DataRawClone { } +pub unsafe trait DataShared : Clone + Data + RawDataClone { } unsafe impl DataShared for OwnedRcRepr {} unsafe impl<'a, A> DataShared for ViewRepr<&'a A> {} diff --git a/src/impl_1d.rs b/src/impl_1d.rs index 765127877..e891e2d4e 100644 --- a/src/impl_1d.rs +++ b/src/impl_1d.rs @@ -12,7 +12,7 @@ use imp_prelude::*; /// # Methods For 1-D Arrays impl ArrayBase - where S: DataRaw, + where S: RawData, { /// Return an vector with the elements of the one-dimensional array. pub fn to_vec(&self) -> Vec diff --git a/src/impl_2d.rs b/src/impl_2d.rs index ddd126d93..9f42d27b5 100644 --- a/src/impl_2d.rs +++ b/src/impl_2d.rs @@ -12,7 +12,7 @@ use imp_prelude::*; /// # Methods For 2-D Arrays impl ArrayBase - where S: DataRaw, + where S: RawData, { /// Return an array view of row `index`. /// diff --git a/src/impl_clone.rs b/src/impl_clone.rs index 34c5599f6..b980f05f4 100644 --- a/src/impl_clone.rs +++ b/src/impl_clone.rs @@ -6,9 +6,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. use imp_prelude::*; -use DataRawClone; +use RawDataClone; -impl Clone for ArrayBase { +impl Clone for ArrayBase { fn clone(&self) -> ArrayBase { unsafe { let (data, ptr) = self.data.clone_with_ptr(self.ptr); @@ -33,4 +33,4 @@ impl Clone for ArrayBase { } } -impl Copy for ArrayBase {} +impl Copy for ArrayBase {} diff --git a/src/impl_methods.rs b/src/impl_methods.rs index f633fb3d1..dc1b4801f 100644 --- a/src/impl_methods.rs +++ b/src/impl_methods.rs @@ -47,7 +47,7 @@ use stacking::stack; /// # Methods For All Array Types impl ArrayBase where - S: DataRaw, + S: RawData, D: Dimension, { /// Return the total number of elements in the array. @@ -503,7 +503,7 @@ where } pub(crate) fn get_ptr_mut(&mut self, index: I) -> Option<*mut A> - where S: DataRawMut, + where S: RawDataMut, I: NdIndex, { // const and mut are separate to enforce &mutness as well as the @@ -1143,7 +1143,7 @@ where /// /// This method is mostly only useful with unsafe code. fn try_ensure_unique(&mut self) - where S: DataRawMut + where S: RawDataMut { debug_assert!(self.pointer_is_inbounds()); S::try_ensure_unique(self); @@ -1204,7 +1204,7 @@ where /// Return a mutable pointer to the first element in the array. #[inline(always)] pub fn as_mut_ptr(&mut self) -> *mut A - where S: DataRawMut + where S: RawDataMut { self.try_ensure_unique(); // for RcArray self.ptr @@ -1219,7 +1219,7 @@ where /// Return a raw mutable view of the array. #[inline] pub fn raw_view_mut(&mut self) -> RawArrayViewMut - where S: DataRawMut + where S: RawDataMut { self.try_ensure_unique(); // for RcArray unsafe { RawArrayViewMut::new_(self.ptr, self.dim.clone(), self.strides.clone()) } diff --git a/src/impl_raw_views.rs b/src/impl_raw_views.rs index 9adb75b42..76396109d 100644 --- a/src/impl_raw_views.rs +++ b/src/impl_raw_views.rs @@ -89,7 +89,7 @@ where self.ptr } else { let offset = stride_offset(index, self.strides.axis(axis)); - // The `.offset()` is safe due to the guarantees of `DataRaw`. + // The `.offset()` is safe due to the guarantees of `RawData`. unsafe { self.ptr.offset(offset) } }; diff --git a/src/lib.rs b/src/lib.rs index fd855854b..1d41cf23d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,9 +153,9 @@ pub use aliases::*; #[allow(deprecated)] pub use data_traits::{ - DataRaw, - DataRawMut, - DataRawClone, + RawData, + RawDataMut, + RawDataClone, Data, DataMut, DataOwned, @@ -197,8 +197,8 @@ mod imp_prelude { pub use ArcArray; pub use { RemoveAxis, - DataRaw, - DataRawMut, + RawData, + RawDataMut, Data, DataMut, DataOwned, @@ -1031,7 +1031,7 @@ pub type Ixs = isize; // // [`.offset()`]: https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset-1 pub struct ArrayBase - where S: DataRaw + where S: RawData { /// Data buffer / ownership information. (If owned, contains the data /// buffer; if borrowed, contains the lifetime and mutability.)