@@ -69,15 +69,12 @@ impl<'a> Reader<'a> {
69
69
where
70
70
T : H5Type ,
71
71
S : TryInto < Selection > ,
72
+ Error : From < S :: Error > ,
72
73
D : ndarray:: Dimension ,
73
74
{
74
75
ensure ! ( !self . obj. is_attr( ) , "Slicing cannot be used on attribute datasets" ) ;
75
76
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 ( ) ?;
81
78
let obj_space = self . obj . space ( ) ?;
82
79
83
80
let out_shape = selection. out_shape ( & obj_space. shape ( ) ) ?;
@@ -151,6 +148,7 @@ impl<'a> Reader<'a> {
151
148
where
152
149
T : H5Type ,
153
150
S : TryInto < Selection > ,
151
+ Error : From < S :: Error > ,
154
152
{
155
153
self . read_slice ( selection)
156
154
}
@@ -168,6 +166,7 @@ impl<'a> Reader<'a> {
168
166
where
169
167
T : H5Type ,
170
168
S : TryInto < Selection > ,
169
+ Error : From < S :: Error > ,
171
170
{
172
171
self . read_slice ( selection)
173
172
}
@@ -240,15 +239,12 @@ impl<'a> Writer<'a> {
240
239
A : Into < ArrayView < ' b , T , D > > ,
241
240
T : H5Type ,
242
241
S : TryInto < Selection > ,
242
+ Error : From < S :: Error > ,
243
243
D : ndarray:: Dimension ,
244
244
{
245
245
ensure ! ( !self . obj. is_attr( ) , "Slicing cannot be used on attribute datasets" ) ;
246
246
247
- let selection = if let Ok ( selection) = selection. try_into ( ) {
248
- selection
249
- } else {
250
- fail ! ( "Selection is not valid for hdf5" )
251
- } ;
247
+ let selection = selection. try_into ( ) ?;
252
248
let obj_space = self . obj . space ( ) ?;
253
249
254
250
let out_shape = selection. out_shape ( & obj_space. shape ( ) ) ?;
@@ -475,6 +471,7 @@ impl Container {
475
471
where
476
472
T : H5Type ,
477
473
S : TryInto < Selection > ,
474
+ Error : From < S :: Error > ,
478
475
{
479
476
self . as_reader ( ) . read_slice_1d ( selection)
480
477
}
@@ -492,6 +489,7 @@ impl Container {
492
489
where
493
490
T : H5Type ,
494
491
S : TryInto < Selection > ,
492
+ Error : From < S :: Error > ,
495
493
{
496
494
self . as_reader ( ) . read_slice_2d ( selection)
497
495
}
@@ -510,6 +508,7 @@ impl Container {
510
508
where
511
509
T : H5Type ,
512
510
S : TryInto < Selection > ,
511
+ Error : From < S :: Error > ,
513
512
D : ndarray:: Dimension ,
514
513
{
515
514
self . as_reader ( ) . read_slice ( selection)
@@ -556,6 +555,7 @@ impl Container {
556
555
A : Into < ArrayView < ' b , T , D > > ,
557
556
T : H5Type ,
558
557
S : TryInto < Selection > ,
558
+ Error : From < S :: Error > ,
559
559
D : ndarray:: Dimension ,
560
560
{
561
561
self . as_writer ( ) . write_slice ( arr, selection)
0 commit comments