Skip to content

Commit

Permalink
Clippy lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mulimoen committed Sep 19, 2023
1 parent 4ef1d46 commit 6f9fa95
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions hdf5-sys/src/h5p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ mod globals {

#[cfg(feature = "1.12.0")]
#[allow(clippy::module_inception)]
pub mod globals {
pub mod globals_inner {
use super::*;
extern_static!(H5P_MAP_CREATE, H5P_CLS_MAP_CREATE_ID_g);
extern_static!(H5P_MAP_ACCESS, H5P_CLS_MAP_ACCESS_ID_g);
Expand All @@ -142,7 +142,7 @@ mod globals {
extern_static!(H5P_REFERENCE_ACCESS_DEFAULT, H5P_LST_REFERENCE_ACCESS_ID_g);
}
#[cfg(feature = "1.12.0")]
pub use globals::*;
pub use globals_inner::*;
}

#[cfg(all(not(feature = "1.8.14"), all(target_env = "msvc", not(feature = "static"))))]
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait ObjectClass: Sized {
let handle = Handle::try_new(id)?;
if Self::is_valid_id_type(handle.id_type()) {
let obj = Self::from_handle(handle);
obj.validate().map(|_| obj)
obj.validate().map(|()| obj)
} else {
Err(From::from(format!("Invalid {} id: {}", Self::NAME, id)))
}
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/hl/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod v1_14_0 {
use super::*;
use hdf5_sys::h5d::H5Dchunk_iter;

/// Borrowed version of [ChunkInfo](crate::dataset::ChunkInfo)
/// Borrowed version of [`ChunkInfo`](crate::dataset::ChunkInfo)
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ChunkInfoRef<'a> {
pub offset: &'a [hsize_t],
Expand Down
4 changes: 2 additions & 2 deletions hdf5/src/hl/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<'a> Reader<'a> {
pub fn read_raw<T: H5Type>(&self) -> Result<Vec<T>> {
let size = self.obj.space()?.size();
let mut vec = Vec::with_capacity(size);
self.read_into_buf(vec.as_mut_ptr(), None, None).map(|_| {
self.read_into_buf(vec.as_mut_ptr(), None, None).map(|()| {
unsafe {
vec.set_len(size);
};
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<'a> Reader<'a> {
let obj_ndim = self.obj.get_shape()?.ndim();
ensure!(obj_ndim == 0, "ndim mismatch: expected scalar, got {}", obj_ndim);
let mut val = mem::MaybeUninit::<T>::uninit();
self.read_into_buf(val.as_mut_ptr(), None, None).map(|_| unsafe { val.assume_init() })
self.read_into_buf(val.as_mut_ptr(), None, None).map(|()| unsafe { val.assume_init() })
}
}

Expand Down
6 changes: 3 additions & 3 deletions hdf5/src/hl/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl DatasetBuilderInner {
Some(dapl) => dapl.clone(),
None => DatasetAccess::try_new()?,
};
self.dapl_builder.apply(&mut dapl).map(|_| dapl)
self.dapl_builder.apply(&mut dapl).map(|()| dapl)
}

fn compute_chunk_shape(&self, dtype: &Datatype, extents: &Extents) -> Result<Option<Vec<Ix>>> {
Expand Down Expand Up @@ -468,15 +468,15 @@ impl DatasetBuilderInner {
Some(dcpl) => dcpl.clone(),
None => DatasetCreate::try_new()?,
};
dcpl_builder.apply(&mut dcpl).map(|_| dcpl)
dcpl_builder.apply(&mut dcpl).map(|()| dcpl)
}

fn build_lcpl(&self) -> Result<LinkCreate> {
let mut lcpl = match &self.lcpl_base {
Some(lcpl) => lcpl.clone(),
None => LinkCreate::try_new()?,
};
self.lcpl_builder.apply(&mut lcpl).map(|_| lcpl)
self.lcpl_builder.apply(&mut lcpl).map(|()| lcpl)
}

fn try_unlink<'n, N: Into<Option<&'n str>>>(&self, name: N) {
Expand Down
3 changes: 2 additions & 1 deletion hdf5/src/hl/plist/dataset_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ impl DatasetAccessBuilder {
Ok(())
}

#[allow(clippy::needless_pass_by_ref_mut)]
pub fn apply(&self, plist: &mut DatasetAccess) -> Result<()> {
h5lock!(self.populate_plist(plist.id()))
}

pub fn finish(&self) -> Result<DatasetAccess> {
h5lock!({
let mut plist = DatasetAccess::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion hdf5/src/hl/plist/dataset_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,15 @@ impl DatasetCreateBuilder {
!self.filters.is_empty()
}

#[allow(clippy::needless_pass_by_ref_mut)]
pub fn apply(&self, plist: &mut DatasetCreate) -> Result<()> {
h5lock!(self.populate_plist(plist.id()))
}

pub fn finish(&self) -> Result<DatasetCreate> {
h5lock!({
let mut plist = DatasetCreate::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
5 changes: 3 additions & 2 deletions hdf5/src/hl/plist/file_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,14 +1482,15 @@ impl FileAccessBuilder {
Ok(())
}

#[allow(clippy::needless_pass_by_ref_mut)]
pub fn apply(&self, plist: &mut FileAccess) -> Result<()> {
h5lock!(self.populate_plist(plist.id()))
}

pub fn finish(&self) -> Result<FileAccess> {
h5lock!({
let mut plist = FileAccess::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down Expand Up @@ -1575,7 +1576,7 @@ impl FileAccess {
}
let relax = relax > 0;
let drv = MultiDriver { files, layout, relax };
drv.validate().map(|_| drv)
drv.validate().map(|()| drv)
}

#[doc(hidden)]
Expand Down
3 changes: 2 additions & 1 deletion hdf5/src/hl/plist/file_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,15 @@ impl FileCreateBuilder {
Ok(())
}

#[allow(clippy::needless_pass_by_ref_mut)]
pub fn apply(&self, plist: &mut FileCreate) -> Result<()> {
h5lock!(self.populate_plist(plist.id()))
}

pub fn finish(&self) -> Result<FileCreate> {
h5lock!({
let mut plist = FileCreate::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion hdf5/src/hl/plist/link_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,15 @@ impl LinkCreateBuilder {
Ok(())
}

#[allow(clippy::needless_pass_by_ref_mut)]
pub fn apply(&self, plist: &mut LinkCreate) -> Result<()> {
h5lock!(self.populate_plist(plist.id()))
}

pub fn finish(&self) -> Result<LinkCreate> {
h5lock!({
let mut plist = LinkCreate::try_new()?;
self.apply(&mut plist).map(|_| plist)
self.apply(&mut plist).map(|()| plist)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion hdf5/src/hl/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn check_coords(coords: &Array2<Ix>, shape: &[Ix]) -> Result<()> {
let ndim = coords.shape()[1];
ensure!(ndim == shape.len(), "Slice ndim ({}) != shape ndim ({})", ndim, shape.len());
for (i, &dim) in shape.iter().enumerate() {
for &d in coords.slice(s![.., i]).iter() {
for &d in coords.slice(s![.., i]) {
ensure!(d < dim, "Index {} out of bounds for axis {} with size {}", d, i, dim);
}
}
Expand Down

0 comments on commit 6f9fa95

Please sign in to comment.