pub fn checked_new(
        lower_bounds: impl Into<GridPoint>,
        sizes: impl Into<GridVector>,
    ) -> Result<Self, GridOverflowError> {
        let lower_bounds = lower_bounds.into();
        let sizes = sizes.into();

        // TODO: Test these error cases.
        // TODO: Replace string error construction with an error enum.
        for i in 0..3 {
            if sizes[i] < 0 {
                return Err(GridOverflowError(format!(
                    "sizes[{}] must be ≥ 0, not {}",
                    i, sizes[i]
                )));
            }
            lower_bounds[i].checked_add(sizes[i]).ok_or_else(|| {
                GridOverflowError(format!("lower_bounds[{}] too large for sizes", i))
            })?;
        }
        Self::checked_volume_helper(sizes)
            .map_err(|()| GridOverflowError(format!("volume too large; {:?} overflows", sizes)))?;

        Ok(Grid {
            lower_bounds,
            sizes,
        })
    }
/// Constructs a [`Grid`] from coordinate lower bounds and sizes.
///
/// For example, if on one axis the lower bound is 5 and the size is 10,
/// then the positions where blocks can exist are numbered 5 through 14
/// (inclusive) and the occupied volume (from a perspective of continuous
/// rather than discrete coordinates) spans 5 to 15.
///
/// Returns [`Err`] if the sizes are non-negative or the resulting range would cause
/// numeric overflow.
///
/// TODO: Rename this to be parallel with from_lower_upper
Constructs a [`Grid`] from coordinate lower bounds and sizes.
For example, if on one axis the lower bound is 5 and the size is 10,
then the positions where blocks can exist are numbered 5 through 14
(inclusive) and the occupied volume (from a perspective of continuous
rather than discrete coordinates) spans 5 to 15.

Returns [`Err`] if the sizes are non-negative or the resulting range would cause
numeric overflow.

Rename this to be parallel with from_lower_upper
Constructs a [ ` Grid ` ] from coordinate lower bounds and sizes . For example if on one axis the lower bound is 5 and the size is 10 then the positions where blocks can exist are numbered 5 through 14 ( inclusive ) and the occupied volume ( from a perspective of continuous rather than discrete coordinates ) spans 5 to 15 . Returns [ ` Err ` ] if the sizes are non - negative or the resulting range would cause numeric overflow . Rename this to be parallel with from_lower_upper
pub fn checked_new(
        lower_bounds: impl Into<GridPoint>,
        sizes: impl Into<GridVector>,
    ) -> Result<Self, GridOverflowError> {
        let lower_bounds = lower_bounds.into();
        let sizes = sizes.into();
        // TODO: Test these error cases.
        // TODO: Replace string error construction with an error enum.
        for i in 0..3 {
            if sizes[i] < 0 {
                return Err(GridOverflowError(format!(
                    "sizes[{}] must be ≥ 0, not {}",
                    i, sizes[i]
                )));
            }
            lower_bounds[i].checked_add(sizes[i]).ok_or_else(|| {
                GridOverflowError(format!("lower_bounds[{}] too large for sizes", i))
            })?;
        }
        Self::checked_volume_helper(sizes)
            .map_err(|()| GridOverflowError(format!("volume too large; {:?} overflows", sizes)))?;
        Ok(Grid {
            lower_bounds,
            sizes,
        })
    }
pub fn checked_new ( lower_bounds : impl Into < GridPoint > , sizes : impl Into < GridVector > , ) -> Result < Self , GridOverflowError > { let lower_bounds = lower_bounds . into ( ) ; let sizes = sizes . into ( ) ; // TODO: Test these error cases. // TODO: Replace string error construction with an error enum. for i in 0 .. 3 { if sizes [ i ] < 0 { return Err ( GridOverflowError ( format ! ( " i sizes [ i ] ) ) ) ; } lower_bounds [ i ] . checked_add ( sizes [ i ] ) . ok_or_else ( | | { GridOverflowError ( format ! ( " " i ) ) } ) ? ; } Self :: checked_volume_helper ( sizes ) . map_err ( | ( ) | GridOverflowError ( format ! ( " " sizes ) ) ) ? ; Ok ( Grid { lower_bounds , sizes , } ) }
Constructs a [`Grid`] from coordinate lower bounds and sizes.
Constructs a [ ` Grid ` ] from coordinate lower bounds and sizes .
lower_bounds
impl Into<GridPoint>
sizes
impl Into<GridVector>