pub type Result<T, E = Yoshi> = Result<T, E>;Available on crate feature
std only.Expand description
Performance-optimized Result alias with mathematical precision guarantees.
This type alias simplifies the use of Result where the error type is
fixed to Yoshi. It automatically adapts between std::result::Result
and core::result::Result based on the enabled features.
§Examples
use yoshi_std::{Result, Yoshi, YoshiKind};
fn divide(a: f64, b: f64) -> Result<f64> {
if b == 0.0 {
return Err(Yoshi::new(YoshiKind::Validation {
field: "divisor".into(),
message: "Division by zero is not allowed".into(),
expected: Some("non-zero".into()),
actual: Some("0.0".into()),
}));
}
Ok(a / b)
}
let result = divide(10.0, 2.0);
assert!(result.is_ok());
assert_eq!(result.unwrap(), 5.0);
let error_result = divide(10.0, 0.0);
assert!(error_result.is_err());Aliased Type§
pub enum Result<T, E = Yoshi> {
Ok(T),
Err(E),
}