| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub enum DynAxesRepr<T> | ||
| { | ||
| Inline(usize, [T; CAP]), |
There was a problem hiding this comment.
I don't understand the limit of 4 here.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is the next PR to address #1506. The aim of this PR is to introduce a minimal trait for representing shapes - an ordered collection of axis lengths for an array. Although this is a starting point for the trait, I suspect I will have to add / modify it as I move through the refactor and see just exactly how/when a Shape is used.
A few design quirks of this trait. First of all, there is no Index bound on Shape, or a default Index implementation. Unfortunately, Index requires returning &T: it requires that the return be borrowed from the indexed type. One of the explicit goals of this rework is to allow constant-sized shapes, including shapes which are entirely defined at compile time and zero-sized. These shapes wouldn't have any value to lend out for the borrow. The same goes for shapes which are computed.
Instead, this design makes two requirements of the shape. First, a function, axis_len, that returns the length of an axis. Second, that the shape can be iterated over.
We use these required methods to define several checks and derived methods on Shape, which are mostly concerned with the existing safety limit that ndarray imposes under the hood: that the number of elements and number of bytes in an array both be less than or equal to isize::MAX.
I also provide structs that implement Shape for both const-dimensionality and dynamic dimensionality.