You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Array0 has the handy into_scalar() method, which from what I gather roughly equates to calling arr.index(Ix0()).
Unfortunately, this isn't available for array views, so we're stuck using the more obscure and verbose syntax for ArrayView0 and ArrayViewMut0. It looks to me like it'd just be a matter to move the into_scalar() impl up to ArrayBase, letting the view representation choose the return type.
Would it be a breaking change? How difficult would it be to implement?
I think @Palladinium may be referring to the .index() method from the IndexLonger trait. It's currently the best way to get an &'a A from an ArrayView0<'a, A, D>. (Note the matching lifetimes.)
I do think it would make sense to add .into_scalar() methods to ArrayView0 and ArrayViewMut0 for convenience. (Those types specifically, not all of ArrayBase<S, Ix0>.) It would not be a breaking change, and it would be easy to implement.
Activity
bluss commentedon Sep 1, 2019
arr.index(Ix0())is the syntax that looks obscure and verbose to me, I'm not sure why you'd use that.The standard way of accessing an element in a 0-dim array is to use a 0-dim index and using indexing notation:
jturner314 commentedon Sep 3, 2019
I think @Palladinium may be referring to the
.index()method from theIndexLongertrait. It's currently the best way to get an&'a Afrom anArrayView0<'a, A, D>. (Note the matching lifetimes.)I do think it would make sense to add
.into_scalar()methods toArrayView0andArrayViewMut0for convenience. (Those types specifically, not all ofArrayBase<S, Ix0>.) It would not be a breaking change, and it would be easy to implement.LukeMathWalker commentedon Sep 8, 2019
Solved by #700