rust-ndarray / ndarray

ndarray: an N-dimensional array with array views, multidimensional slicing, and efficient operations
https://docs.rs/ndarray/
Apache License 2.0
3.63k stars 307 forks source link

Make iterators covariant in element type #1417

Closed bluss closed 3 months ago

bluss commented 3 months ago

The internal Baseiter type underlies most of the ndarray iterators, and it used *mut A for element type A. Update it to use NonNull<A> which behaves identically except it's guaranteed to be non-null and is covariant w.r.t the parameter A.

Add compile test from the issue. The second commit continues the "conversion", using NonNull more consistently in Baseiter's Iterator impl.

Fixes #1290