@@ -201,6 +201,7 @@ mod imp_prelude {
201
201
DataMut ,
202
202
DataOwned ,
203
203
DataShared ,
204
+ RawViewRepr ,
204
205
ViewRepr ,
205
206
Ix , Ixs ,
206
207
} ;
@@ -1127,6 +1128,57 @@ pub type ArrayView<'a, A, D> = ArrayBase<ViewRepr<&'a A>, D>;
1127
1128
/// [ab]: struct.ArrayBase.html
1128
1129
pub type ArrayViewMut < ' a , A , D > = ArrayBase < ViewRepr < & ' a mut A > , D > ;
1129
1130
1131
+ /// A read-only array view without a lifetime.
1132
+ ///
1133
+ /// This is similar to [`ArrayView`] but does not carry any lifetime or
1134
+ /// ownership information, and its data cannot be read without an unsafe
1135
+ /// conversion into an [`ArrayView`]. The relationship between `RawArrayView`
1136
+ /// and [`ArrayView`] is somewhat analogous to the relationship between `*const
1137
+ /// T` and `&T`, but `RawArrayView` has additional requirements that `*const T`
1138
+ /// does not, such as alignment and non-nullness.
1139
+ ///
1140
+ /// [`ArrayView`]: type.ArrayView.html
1141
+ ///
1142
+ /// The `RawArrayView<A, D>` is parameterized by `A` for the element type and
1143
+ /// `D` for the dimensionality.
1144
+ ///
1145
+ /// Raw array views have all the methods of an array (see
1146
+ /// [`ArrayBase`](struct.ArrayBase.html)).
1147
+ ///
1148
+ /// See also [`RawArrayViewMut`](type.RawArrayViewMut.html).
1149
+ ///
1150
+ /// # Warning
1151
+ ///
1152
+ /// You can't use this type wih an arbitrary raw pointer; see
1153
+ /// [`from_shape_ptr`](#method.from_shape_ptr) for details.
1154
+ pub type RawArrayView < A , D > = ArrayBase < RawViewRepr < * const A > , D > ;
1155
+
1156
+ /// A mutable array view without a lifetime.
1157
+ ///
1158
+ /// This is similar to [`ArrayViewMut`] but does not carry any lifetime or
1159
+ /// ownership information, and its data cannot be read/written without an
1160
+ /// unsafe conversion into an [`ArrayViewMut`]. The relationship between
1161
+ /// `RawArrayViewMut` and [`ArrayViewMut`] is somewhat analogous to the
1162
+ /// relationship between `*mut T` and `&mut T`, but `RawArrayViewMut` has
1163
+ /// additional requirements that `*mut T` does not, such as alignment and
1164
+ /// non-nullness.
1165
+ ///
1166
+ /// [`ArrayViewMut`]: type.ArrayViewMut.html
1167
+ ///
1168
+ /// The `RawArrayViewMut<A, D>` is parameterized by `A` for the element type
1169
+ /// and `D` for the dimensionality.
1170
+ ///
1171
+ /// Raw array views have all the methods of an array (see
1172
+ /// [`ArrayBase`](struct.ArrayBase.html)).
1173
+ ///
1174
+ /// See also [`RawArrayView`](type.RawArrayView.html).
1175
+ ///
1176
+ /// # Warning
1177
+ ///
1178
+ /// You can't use this type wih an arbitrary raw pointer; see
1179
+ /// [`from_shape_ptr`](#method.from_shape_ptr) for details.
1180
+ pub type RawArrayViewMut < A , D > = ArrayBase < RawViewRepr < * mut A > , D > ;
1181
+
1130
1182
/// Array's representation.
1131
1183
///
1132
1184
/// *Don’t use this type directly—use the type alias
@@ -1154,6 +1206,23 @@ impl<A> Clone for OwnedArcRepr<A> {
1154
1206
}
1155
1207
}
1156
1208
1209
+ /// Array pointer’s representation.
1210
+ ///
1211
+ /// *Don’t use this type directly—use the type aliases
1212
+ /// [`RawArrayView`](type.RawArrayView.html) /
1213
+ /// [`RawArrayViewMut`](type.RawArrayViewMut.html) for the array type!*
1214
+ #[ derive( Copy , Clone ) ]
1215
+ // This is just a marker type, to carry the mutability and element type.
1216
+ pub struct RawViewRepr < A > {
1217
+ ptr : PhantomData < A > ,
1218
+ }
1219
+
1220
+ impl < A > RawViewRepr < A > {
1221
+ #[ inline( always) ]
1222
+ fn new ( ) -> Self {
1223
+ RawViewRepr { ptr : PhantomData }
1224
+ }
1225
+ }
1157
1226
1158
1227
/// Array view’s representation.
1159
1228
///
0 commit comments