message: Replace num-integer in src/error.rs
diff: @@ -7,8 +7,6 @@ use std::ptr;
  use lazy_static::lazy_static;
  use ndarray::ShapeError;
  -use num_integer::Integer;
  -use num_traits::{Bounded, Zero};
  use parking_lot::Mutex;
  use hdf5_sys::h5e::{
  @@ -233,7 +231,7 @@ pub enum Error {
  /// A type for results generated by HDF5-related functions where the `Err` type is
  /// set to `hdf5::Error`.
  -pub type Result<T> = ::std::result::Result<T, Error>;
  +pub type Result<T, E = Error> = ::std::result::Result<T, E>;
  impl Error {
  pub fn query() -> Option<Self> {
  @@ -287,27 +285,51 @@ impl From<ShapeError> for Error {
  }
  }
  -pub fn is_err_code<T>(value: T) -> bool
  -where
  - T: Integer + Zero + Bounded + Copy,
  -{
  - if T::min_value() < T::zero() {
  - value < T::zero()
  - } else {
  - value == T::zero()
  +pub fn h5check<T: H5ErrorCode>(value: T) -> Result<T> {
  + H5ErrorCode::h5check(value)
  }
  +
  +#[allow(unused)]
  +pub fn is_err_code<T: H5ErrorCode>(value: T) -> bool {
  + H5ErrorCode::is_err_code(value)
  }
  -pub fn h5check<T>(value: T) -> Result<T>
  -where
  - T: Integer + Zero + Bounded + Copy,
  -{
  - if is_err_code(value) {
  +pub trait H5ErrorCode: Copy {
  + fn is_err_code(value: Self) -> bool;
  + fn h5check(value: Self) -> Result<Self> {
  + if Self::is_err_code(value) {
  Error::query().map_or_else(|| Ok(value), Err)
  } else {
  Ok(value)
  }
  }
  +}
  +
  +impl H5ErrorCode for hsize_t {
  + fn is_err_code(value: Self) -> bool {
  + value == 0
  + }
  +}
  +impl H5ErrorCode for herr_t {
  + fn is_err_code(value: Self) -> bool {
  + value < 0
  + }
  +}
  +impl H5ErrorCode for hid_t {
  + fn is_err_code(value: Self) -> bool {
  + value < 0
  + }
  +}
  +impl H5ErrorCode for libc::ssize_t {
  + fn is_err_code(value: Self) -> bool {
  + value < 0
  + }
  +}
  +impl H5ErrorCode for size_t {
  + fn is_err_code(value: Self) -> bool {
  + value == 0
  + }
  +}
  #[cfg(test)]
  pub mod tests {
  