File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,15 @@ impl DataType {
169
169
}
170
170
171
171
/// Represents that a type can be an element of `PyArray`.
172
- pub trait Element : Clone + Send {
172
+ ///
173
+ /// A type `T` that implements this trait should be safe when managed in numpy array,
174
+ /// thus implementing this trait is marked unsafe.
175
+ /// For example, we don't support `PyObject` because of [an odd segfault](https://github.com/PyO3/rust-numpy/pull/143),
176
+ /// although numpy itself supports it.
177
+ ///
178
+ /// Also, we lack supports for some other types like unicode.
179
+ /// If you come up with a nice implementation, we're happy to receive your PR :)
180
+ pub unsafe trait Element : Clone + Send {
173
181
/// `DataType` corresponding to this type.
174
182
const DATA_TYPE : DataType ;
175
183
@@ -191,7 +199,7 @@ pub trait Element: Clone + Send {
191
199
192
200
macro_rules! impl_num_element {
193
201
( $t: ty, $npy_dat_t: ident $( , $npy_types: ident) +) => {
194
- impl Element for $t {
202
+ unsafe impl Element for $t {
195
203
const DATA_TYPE : DataType = DataType :: $npy_dat_t;
196
204
fn is_same_type( dtype: & PyArrayDescr ) -> bool {
197
205
$( dtype. get_typenum( ) == NPY_TYPES :: $npy_types as i32 ||) + false
You can’t perform that action at this time.
0 commit comments