Skip to content

Commit 415f3dc

Browse files
committed
Fix all clippy errors in all crates
1 parent 7b168df commit 415f3dc

File tree

15 files changed

+50
-57
lines changed

15 files changed

+50
-57
lines changed

hdf5-derive/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,8 @@ fn find_hdf5_rename(attrs: &[Attribute]) -> Option<String> {
134134
let mut rename = None;
135135
let attr = attrs.iter().find(|a| a.path().is_ident("hdf5"))?;
136136
attr.parse_nested_meta(|meta| {
137-
if meta.path.is_ident("rename") {
138-
if rename.is_none() {
139-
rename = Some(meta.value()?.parse::<LitStr>()?.value());
140-
}
137+
if meta.path.is_ident("rename") && rename.is_none() {
138+
rename = Some(meta.value()?.parse::<LitStr>()?.value());
141139
}
142140
Ok(())
143141
})

hdf5-sys/src/h5f.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,21 +341,16 @@ mod hdf5_1_10_1 {
341341
use super::*;
342342

343343
#[repr(C)]
344-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Debug)]
344+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Debug, Default)]
345345
pub enum H5F_fspace_strategy_t {
346+
#[default]
346347
H5F_FSPACE_STRATEGY_FSM_AGGR = 0,
347348
H5F_FSPACE_STRATEGY_PAGE = 1,
348349
H5F_FSPACE_STRATEGY_AGGR = 2,
349350
H5F_FSPACE_STRATEGY_NONE = 3,
350351
H5F_FSPACE_STRATEGY_NTYPES = 4,
351352
}
352353

353-
impl Default for H5F_fspace_strategy_t {
354-
fn default() -> Self {
355-
H5F_FSPACE_STRATEGY_FSM_AGGR
356-
}
357-
}
358-
359354
pub use self::H5F_fspace_strategy_t::*;
360355

361356
extern "C" {

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl ErrorFrame {
123123
func: func.into(),
124124
major: major.into(),
125125
minor: minor.into(),
126-
description: format!("{}(): {}", func, desc),
126+
description: format!("{func}(): {desc}"),
127127
}
128128
}
129129

@@ -265,7 +265,7 @@ impl StdError for Error {}
265265

266266
impl From<ShapeError> for Error {
267267
fn from(err: ShapeError) -> Self {
268-
format!("shape error: {}", err).into()
268+
format!("shape error: {err}").into()
269269
}
270270
}
271271

src/handle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl Handle {
2020
// Drop on an invalid handle could cause closing an unrelated object
2121
// in the destructor, hence it's important to prevent the drop here.
2222
mem::forget(handle);
23-
Err(From::from(format!("Invalid handle id: {}", id)))
23+
Err(From::from(format!("Invalid handle id: {id}")))
2424
}
2525
}
2626

src/hl/container.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a> Reader<'a> {
7878
let selection = selection.try_into()?;
7979
let obj_space = self.obj.space()?;
8080

81-
let out_shape = selection.out_shape(&obj_space.shape())?;
81+
let out_shape = selection.out_shape(obj_space.shape())?;
8282
let out_size: Ix = out_shape.iter().product();
8383
let fspace = obj_space.select(selection)?;
8484

@@ -250,7 +250,7 @@ impl<'a> Writer<'a> {
250250
let selection = selection.try_into()?;
251251
let obj_space = self.obj.space()?;
252252

253-
let out_shape = selection.out_shape(&obj_space.shape())?;
253+
let out_shape = selection.out_shape(obj_space.shape())?;
254254
let out_size: Ix = out_shape.iter().product();
255255
let fspace = obj_space.select(selection)?;
256256
let view = arr.into();
@@ -392,7 +392,7 @@ impl io::Read for ByteReader {
392392
let pos = self.pos as usize;
393393
let amt = std::cmp::min(buf.len(), self.remaining_len());
394394
let selection = Selection::new(pos..pos + amt);
395-
let out_shape = selection.out_shape(&self.obj_space.shape())?;
395+
let out_shape = selection.out_shape(self.obj_space.shape())?;
396396
let fspace = self.obj_space.select(selection)?;
397397
let mspace = Dataspace::try_new(&out_shape)?;
398398
h5call!(H5Dread(

src/hl/dataspace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl ObjectClass for Dataspace {
3636

3737
fn short_repr(&self) -> Option<String> {
3838
if let Ok(e) = self.extents() {
39-
Some(format!("{}", e))
39+
Some(format!("{e}"))
4040
} else {
4141
Some("(invalid)".into())
4242
}
@@ -200,7 +200,7 @@ impl Dataspace {
200200
}
201201

202202
pub fn select<S: Into<Selection>>(&self, selection: S) -> Result<Self> {
203-
let raw_sel = selection.into().into_raw(&self.shape())?;
203+
let raw_sel = selection.into().into_raw(self.shape())?;
204204
self.select_raw(raw_sel)
205205
}
206206

src/hl/datatype.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ impl From<H5T_order_t> for ByteOrder {
156156

157157
impl Datatype {
158158
/// Get the total size of the datatype in bytes.
159+
#[allow(clippy::unnecessary_cast)]
159160
pub fn size(&self) -> usize {
160161
h5lock!(H5Tget_size(self.id())) as usize
161162
}
@@ -217,6 +218,7 @@ impl Datatype {
217218

218219
h5lock!({
219220
let id = self.id();
221+
#[allow(clippy::unnecessary_cast)]
220222
let size = H5Tget_size(id) as usize;
221223
match H5Tget_class(id) {
222224
H5T_class_t::H5T_INTEGER => {

src/hl/extents.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ pub struct Extent {
1818

1919
impl Debug for Extent {
2020
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21-
write!(f, "Extent({})", self)
21+
write!(f, "Extent({self})")
2222
}
2323
}
2424

2525
impl Display for Extent {
2626
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27+
let dim = self.dim;
2728
if let Some(max) = self.max {
2829
if self.dim == max {
29-
write!(f, "{}", self.dim)
30+
write!(f, "{dim}")
3031
} else {
31-
write!(f, "{}..={}", self.dim, max)
32+
write!(f, "{dim}..={max}")
3233
}
3334
} else {
34-
write!(f, "{}..", self.dim)
35+
write!(f, "{dim}..")
3536
}
3637
}
3738
}
@@ -190,7 +191,7 @@ impl Deref for SimpleExtents {
190191

191192
impl Debug for SimpleExtents {
192193
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
193-
write!(f, "SimpleExtents({})", self)
194+
write!(f, "SimpleExtents({self})")
194195
}
195196
}
196197

@@ -202,7 +203,7 @@ impl Display for SimpleExtents {
202203
write!(f, "({},)", self[0])
203204
} else {
204205
let extents = self.iter().map(ToString::to_string).collect::<Vec<_>>().join(", ");
205-
write!(f, "({})", extents)
206+
write!(f, "({extents})")
206207
}
207208
}
208209
}
@@ -466,7 +467,7 @@ impl Display for Extents {
466467
match self {
467468
Self::Null => write!(f, "null"),
468469
Self::Scalar => write!(f, "scalar"),
469-
Self::Simple(ref e) => write!(f, "{}", e),
470+
Self::Simple(ref e) => write!(f, "{e}"),
470471
}
471472
}
472473
}

src/hl/file.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl ObjectClass for File {
5353
None => String::new(),
5454
};
5555
let mode = if self.is_read_only() { "read-only" } else { "read/write" };
56-
Some(format!("\"{}\" ({})", basename, mode))
56+
Some(format!("\"{basename}\" ({mode})"))
5757
}
5858
}
5959

@@ -227,9 +227,7 @@ impl FileBuilder {
227227
}
228228
}
229229
let filename = to_cstring(
230-
filename
231-
.to_str()
232-
.ok_or_else(|| format!("Invalid UTF-8 in file name: {:?}", filename))?,
230+
filename.to_str().ok_or_else(|| format!("Invalid UTF-8 in file name: {filename:?}"))?,
233231
)?;
234232
let flags = match mode {
235233
OpenMode::Read => H5F_ACC_RDONLY,

src/hl/filters.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,12 @@ pub(crate) fn validate_filters(filters: &[Filter], type_class: H5T_class_t) -> R
553553
}
554554
_ => fail!("Can only use scale-offset with ints/floats, got: {:?}", type_class),
555555
}
556-
} else if let Filter::SZip(_, _) = filter {
556+
} else if matches!(filter, Filter::SZip(_, _)) {
557557
// https://github.com/h5py/h5py/issues/953
558558
if map.contains_key(&H5Z_FILTER_FLETCHER32) {
559559
fail!("Fletcher32 filter must be placed after szip filter");
560560
}
561-
} else if let Filter::Shuffle = filter {
561+
} else if matches!(filter, Filter::Shuffle) {
562562
if let Some(comp_filter) = comp_filter {
563563
fail!("Shuffle filter placed after compression filter: {:?}", comp_filter);
564564
}

0 commit comments

Comments
 (0)