@@ -69,15 +69,12 @@ impl<'a> Reader<'a> {
6969 where
7070 T : H5Type ,
7171 S : TryInto < Selection > ,
72+ Error : From < S :: Error > ,
7273 D : ndarray:: Dimension ,
7374 {
7475 ensure ! ( !self . obj. is_attr( ) , "Slicing cannot be used on attribute datasets" ) ;
7576
76- let selection = if let Ok ( selection) = selection. try_into ( ) {
77- selection
78- } else {
79- fail ! ( "Selection is not valid for hdf5" )
80- } ;
77+ let selection = selection. try_into ( ) ?;
8178 let obj_space = self . obj . space ( ) ?;
8279
8380 let out_shape = selection. out_shape ( & obj_space. shape ( ) ) ?;
@@ -153,6 +150,7 @@ impl<'a> Reader<'a> {
153150 where
154151 T : H5Type ,
155152 S : TryInto < Selection > ,
153+ Error : From < S :: Error > ,
156154 {
157155 self . read_slice ( selection)
158156 }
@@ -170,6 +168,7 @@ impl<'a> Reader<'a> {
170168 where
171169 T : H5Type ,
172170 S : TryInto < Selection > ,
171+ Error : From < S :: Error > ,
173172 {
174173 self . read_slice ( selection)
175174 }
@@ -242,15 +241,12 @@ impl<'a> Writer<'a> {
242241 A : Into < ArrayView < ' b , T , D > > ,
243242 T : H5Type ,
244243 S : TryInto < Selection > ,
244+ Error : From < S :: Error > ,
245245 D : ndarray:: Dimension ,
246246 {
247247 ensure ! ( !self . obj. is_attr( ) , "Slicing cannot be used on attribute datasets" ) ;
248248
249- let selection = if let Ok ( selection) = selection. try_into ( ) {
250- selection
251- } else {
252- fail ! ( "Selection is not valid for hdf5" )
253- } ;
249+ let selection = selection. try_into ( ) ?;
254250 let obj_space = self . obj . space ( ) ?;
255251
256252 let out_shape = selection. out_shape ( & obj_space. shape ( ) ) ?;
@@ -477,6 +473,7 @@ impl Container {
477473 where
478474 T : H5Type ,
479475 S : TryInto < Selection > ,
476+ Error : From < S :: Error > ,
480477 {
481478 self . as_reader ( ) . read_slice_1d ( selection)
482479 }
@@ -494,6 +491,7 @@ impl Container {
494491 where
495492 T : H5Type ,
496493 S : TryInto < Selection > ,
494+ Error : From < S :: Error > ,
497495 {
498496 self . as_reader ( ) . read_slice_2d ( selection)
499497 }
@@ -512,6 +510,7 @@ impl Container {
512510 where
513511 T : H5Type ,
514512 S : TryInto < Selection > ,
513+ Error : From < S :: Error > ,
515514 D : ndarray:: Dimension ,
516515 {
517516 self . as_reader ( ) . read_slice ( selection)
@@ -558,6 +557,7 @@ impl Container {
558557 A : Into < ArrayView < ' b , T , D > > ,
559558 T : H5Type ,
560559 S : TryInto < Selection > ,
560+ Error : From < S :: Error > ,
561561 D : ndarray:: Dimension ,
562562 {
563563 self . as_writer ( ) . write_slice ( arr, selection)
0 commit comments