@@ -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 ( ) ) ?;
@@ -153,6 +150,7 @@ impl<'a> Reader<'a> {
153
150
where
154
151
T : H5Type ,
155
152
S : TryInto < Selection > ,
153
+ Error : From < S :: Error > ,
156
154
{
157
155
self . read_slice ( selection)
158
156
}
@@ -170,6 +168,7 @@ impl<'a> Reader<'a> {
170
168
where
171
169
T : H5Type ,
172
170
S : TryInto < Selection > ,
171
+ Error : From < S :: Error > ,
173
172
{
174
173
self . read_slice ( selection)
175
174
}
@@ -242,15 +241,12 @@ impl<'a> Writer<'a> {
242
241
A : Into < ArrayView < ' b , T , D > > ,
243
242
T : H5Type ,
244
243
S : TryInto < Selection > ,
244
+ Error : From < S :: Error > ,
245
245
D : ndarray:: Dimension ,
246
246
{
247
247
ensure ! ( !self . obj. is_attr( ) , "Slicing cannot be used on attribute datasets" ) ;
248
248
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 ( ) ?;
254
250
let obj_space = self . obj . space ( ) ?;
255
251
256
252
let out_shape = selection. out_shape ( & obj_space. shape ( ) ) ?;
@@ -477,6 +473,7 @@ impl Container {
477
473
where
478
474
T : H5Type ,
479
475
S : TryInto < Selection > ,
476
+ Error : From < S :: Error > ,
480
477
{
481
478
self . as_reader ( ) . read_slice_1d ( selection)
482
479
}
@@ -494,6 +491,7 @@ impl Container {
494
491
where
495
492
T : H5Type ,
496
493
S : TryInto < Selection > ,
494
+ Error : From < S :: Error > ,
497
495
{
498
496
self . as_reader ( ) . read_slice_2d ( selection)
499
497
}
@@ -512,6 +510,7 @@ impl Container {
512
510
where
513
511
T : H5Type ,
514
512
S : TryInto < Selection > ,
513
+ Error : From < S :: Error > ,
515
514
D : ndarray:: Dimension ,
516
515
{
517
516
self . as_reader ( ) . read_slice ( selection)
@@ -558,6 +557,7 @@ impl Container {
558
557
A : Into < ArrayView < ' b , T , D > > ,
559
558
T : H5Type ,
560
559
S : TryInto < Selection > ,
560
+ Error : From < S :: Error > ,
561
561
D : ndarray:: Dimension ,
562
562
{
563
563
self . as_writer ( ) . write_slice ( arr, selection)
0 commit comments