Skip to content

Commit 2dfbd19

Browse files
committed
(clippy fixes)
1 parent 3112109 commit 2dfbd19

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

hdf5-rs/src/hl/container.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,20 @@ impl<'a> Reader<'a> {
8686
}
8787

8888
if shape.ndim() == 0 {
89-
// Fall back to a simple read for the scalar case
90-
// Slicing has no effect
89+
// Fall back to a simple read for the scalar case, slicing has no effect
9190
self.read()
9291
} else {
9392
let fspace = self.obj.space()?;
9493
let out_shape = fspace.select_slice(slice)?;
9594

96-
// Remove dimensions from out_shape that were an
97-
//SliceOrIndex::Index in the slice
98-
let reduced_shape: Vec<usize> = slice_s
95+
// Remove dimensions from out_shape that were SliceOrIndex::Index in the slice
96+
let reduced_shape: Vec<_> = slice_s
9997
.iter()
10098
.zip(out_shape.iter().cloned())
101-
.filter(|(slc, _)| match slc {
102-
SliceOrIndex::Index(_) => false,
103-
_ => true,
99+
.filter_map(|(slc, sz)| match slc {
100+
SliceOrIndex::Index(_) => None,
101+
_ => Some(sz),
104102
})
105-
.map(|(_, sz)| sz)
106103
.collect();
107104

108105
let mspace = Dataspace::try_new(&out_shape, false)?;
@@ -286,14 +283,11 @@ impl<'a> Writer<'a> {
286283
let mut data_shape_hydrated = Vec::new();
287284
let mut pos = 0;
288285
for s in slice_s {
289-
match s {
290-
SliceOrIndex::Index(_) => {
291-
data_shape_hydrated.push(1);
292-
}
293-
_ => {
294-
data_shape_hydrated.push(data_shape[pos]);
295-
pos += 1;
296-
}
286+
if let SliceOrIndex::Index(_) = s {
287+
data_shape_hydrated.push(1);
288+
} else {
289+
data_shape_hydrated.push(data_shape[pos]);
290+
pos += 1;
297291
}
298292
}
299293

0 commit comments

Comments
 (0)