pub enum SurfaceError {
XBelow {
coordinate: u16,
bound: u16,
},
XAbove {
coordinate: u16,
bound: u16,
},
YBelow {
coordinate: u16,
bound: u16,
},
YAbove {
coordinate: u16,
bound: u16,
},
}Expand description
A coordinate fell outside the declared domain on a side selecting
Boundary::Error.
The four variants distinguish the four sides, so a caller never has to infer which axis rejected the input. Each carries the coordinate that was supplied and the bound that applied to it.
This enum is deliberately not #[non_exhaustive]. The v0.1 contract fixes
exactly these four outcomes: shape mismatches are type errors, axis
invariants are checked when the surface is defined, and the arithmetic
cannot overflow for valid operands. Exhaustive matching without a wildcard
arm is therefore both possible and intended.
Variants§
XBelow
The X coordinate was below the first X knot.
Fields
XAbove
The X coordinate was above the last X knot.
Fields
YBelow
The Y coordinate was below the first Y knot.
Fields
YAbove
The Y coordinate was above the last Y knot.
Implementations§
Source§impl SurfaceError
impl SurfaceError
Sourcepub const fn coordinate(&self) -> u16
pub const fn coordinate(&self) -> u16
Returns the coordinate that was rejected, whichever side reported it.
§Examples
use ph_surfaces::SurfaceError;
let error = SurfaceError::YAbove {
coordinate: 900,
bound: 500,
};
assert_eq!(error.coordinate(), 900);
assert_eq!(error.bound(), 500);Trait Implementations§
Source§impl Clone for SurfaceError
impl Clone for SurfaceError
Source§fn clone(&self) -> SurfaceError
fn clone(&self) -> SurfaceError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SurfaceError
Source§impl Debug for SurfaceError
impl Debug for SurfaceError
Source§impl Display for SurfaceError
impl Display for SurfaceError
impl Eq for SurfaceError
Source§impl Error for SurfaceError
impl Error for SurfaceError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()