File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -238,3 +238,25 @@ unsafe impl<'a> NdIndex<IxDyn> for &'a [Ix] {
238238 . sum ( )
239239 }
240240}
241+
242+ unsafe impl < ' a > NdIndex < IxDyn > for & ' a Vec < Ix > {
243+ fn index_checked ( & self , dim : & IxDyn , strides : & IxDyn ) -> Option < isize > {
244+ stride_offset_checked ( dim. ix ( ) , strides. ix ( ) , * self )
245+ }
246+ fn index_unchecked ( & self , strides : & IxDyn ) -> isize {
247+ zip ( strides. ix ( ) , * self )
248+ . map ( |( & s, & i) | stride_offset ( i, s) )
249+ . sum ( )
250+ }
251+ }
252+
253+ unsafe impl < ' a > NdIndex < IxDyn > for Vec < Ix > {
254+ fn index_checked ( & self , dim : & IxDyn , strides : & IxDyn ) -> Option < isize > {
255+ stride_offset_checked ( dim. ix ( ) , strides. ix ( ) , self )
256+ }
257+ fn index_unchecked ( & self , strides : & IxDyn ) -> isize {
258+ zip ( strides. ix ( ) , self )
259+ . map ( |( & s, i) | stride_offset ( * i, s) )
260+ . sum ( )
261+ }
262+ }
You can’t perform that action at this time.
0 commit comments