検索
Results of 1 - 2 of about 2 for MathError (0.001 sec.)
- ? - Rust By Example 日本語版 11228
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...ok expression. mod checked { #[derive(Debug)] enum MathError { DivisionByZero, NonPositiveLogarithm, NegativeSq...uareRoot, } type MathResult = Result<f64, MathError>; fn div(x: f64, y: f64) -> MathResult { if y == 0....0 { Err(MathError::DivisionByZero) } else { Ok(x / y) } } fn sqrt(x:...f64) -> MathResult { if x < 0.0 { Err(MathError::NegativeSquareRoot) } else { Ok(x.sqrt()) } } fn... - https://man.plustar.jp/rust/example/std/result/question_mark.html - [similar]
- Result - Rust By Example 日本語版 7485
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...したい、数学的な「エラー」 #[derive(Debug)] pub enum MathError { DivisionByZero, NonPositiveLogarithm, NegativeSq...uareRoot, } pub type MathResult = Result<f64, MathError>; pub fn div(x: f64, y: f64) -> MathResult { if y...代わりに`Err`でラップされた失敗の理由を返そう。 Err(MathError::DivisionByZero) } else { // This operation is val...b fn sqrt(x: f64) -> MathResult { if x < 0.0 { Err(MathError::NegativeSquareRoot) } else { Ok(x.sqrt()) } } pub... - https://man.plustar.jp/rust/example/std/result.html - [similar]
PREV
1
NEXT