nalgebra_lapack/
lapack_error.rs

1/// Newtype for a LAPACK error code.
2#[derive(Debug, Copy, Clone, PartialEq, Eq, thiserror::Error)]
3#[error("{0}")]
4pub struct LapackErrorCode(pub(crate) i32);
5
6impl PartialEq<i32> for LapackErrorCode {
7    #[inline]
8    fn eq(&self, other: &i32) -> bool {
9        self == &LapackErrorCode(*other)
10    }
11}
12
13/// Utility function to check the info return value of a LAPACK function.
14pub(crate) fn check_lapack_info(info: i32) -> Result<(), LapackErrorCode> {
15    if info == 0 {
16        Ok(())
17    } else {
18        Err(LapackErrorCode(info))
19    }
20}