ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

Make the aview0, aview1, and aview2 free functions be const fns

Open jturner314 opened this issue 3 years ago • 2 comments

This is something I've wanted for a long time; it allows for creation of const ArrayViews. With Rust 1.57, it's now possible. (This was blocked on the ability to panic in const fns.)

This PR also makes the Ix0, …, Ix6 free functions into const fns.

Unfortunately, the const fn implementations of aview0, aview1, and aview2 cannot use some existing internal functionality which would simplify the implementation, especially those which require the Dimension trait, since const traits / trait impls are not yet available. I think the proposed implementations are simple enough, though.

This will have a merge conflict with #1131. I'll fix it up to no longer conflict once #1131 is merged, assuming #1131 is merged first.

This is a breaking change in the sense that it requires Rust 1.57.

jturner314 avatar Dec 07 '21 06:12 jturner314

ArrayRef is hopefully coming in 0.16. I don't know if these conflict, but I suggest that these changes have to stand back if they can't be realized in the ArrayRef update.

bluss avatar Dec 07 '21 17:12 bluss

ArrayRef is hopefully coming in 0.16. I don't know if these conflict, but I suggest that these changes have to stand back if they can't be realized in the ArrayRef update.

I don't see any reason why they'd conflict, but if you'd feel more comfortable with waiting until later to do this, that would be fine with me. The only breaking change in this PR is the minimum Rust version, so it would be good to at least update the MSRV in the next breaking release, unless you consider Rust 1.57 to be too new.

jturner314 avatar Dec 08 '21 01:12 jturner314

There are already breaking changes in the master branch (#980), so continue with this here. Thanks for this one.

bluss avatar Mar 10 '24 12:03 bluss