loeres-backend-std 0.12.1

Loeres dynamic dense/sparse storage and server numerical adapters. std, heap-backed; server-only.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Internal helpers shared by the dynamic storage adapters.

use loeres::SolverError;

/// The dimension error for a mismatch between `lhs` and `rhs`, applying the
/// checked `u32` payload-fallback rule (RFC 007 ยง3.2, Correction 2): if both
/// values fit `u32`, `DimensionMismatch { lhs, rhs }`; otherwise the non-payload
/// `InvalidDimension`. Never truncates.
pub(crate) fn dimension_mismatch(lhs: usize, rhs: usize) -> SolverError {
    match (u32::try_from(lhs), u32::try_from(rhs)) {
        (Ok(lhs), Ok(rhs)) => SolverError::DimensionMismatch { lhs, rhs },
        _ => SolverError::InvalidDimension,
    }
}