Skip to content

Commit c581425

Browse files
committed
Revise the document for Element with using #Safety
1 parent ebcd58b commit c581425

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/dtype.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,17 @@ impl DataType {
170170

171171
/// Represents that a type can be an element of `PyArray`.
172172
///
173+
/// Currently, only integer/float/complex types are supported.
174+
/// If you come up with a nice implementation for some other types, we're happy to receive your PR :)
175+
/// You may refer to the [numpy document](https://numpy.org/doc/stable/reference/c-api/dtype.html#enumerated-types)
176+
/// for all types that numpy supports.
177+
///
178+
/// # Safety
179+
///
173180
/// A type `T` that implements this trait should be safe when managed in numpy array,
174181
/// thus implementing this trait is marked unsafe.
175182
/// For example, we don't support `PyObject` because of [an odd segfault](https://github.com/PyO3/rust-numpy/pull/143),
176183
/// 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 :)
180184
pub unsafe trait Element: Clone + Send {
181185
/// `DataType` corresponding to this type.
182186
const DATA_TYPE: DataType;

0 commit comments

Comments
 (0)