検索
Results of 1 - 10 of about 34 for Ok (0.002 sec.)
- Unit testing - Rust By Example 日本語版 15034
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...::test_bad_add ... FAILED test tests::test_add ... ok failures: ---- tests::test_bad_add stdout ---- thr...: f64) -> Result<f64, String> { if number >= 0.0 { Ok(number.powf(0.5)) } else { Err("negative floats do...{ let x = 4.0; assert_eq!(sqrt(x)?.powf(2.0), x); Ok(()) } } See "The Edition Guide" for more details....est running 3 tests test tests::test_any_panic ... ok test tests::test_divide ... ok test tests::test_sp... - https://man.plustar.jp/rust/example/testing/unit_testing.html - [similar]
- Result - Rust By Example 日本語版 10688
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...します。 列挙型 Result<T, E> は2つの値をとりえます。 Ok(value) ... これはオペレーションが成功したことを意味...operation is valid, return the result wrapped in `Ok` // このオペレーションは問題がないので、結果を`Ok`...でラップして返そう。 Ok(x / y) } } pub fn sqrt(x: f64) -> MathResult { if...0.0 { Err(MathError::NegativeSquareRoot) } else { Ok(x.sqrt()) } } pub fn ln(x: f64) -> MathResult { if... - https://man.plustar.jp/rust/example/std/result.html - [similar]
- ? - Rust By Example 日本語版 10049
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...expands to an early Err(From::from(err)) , and the Ok(ok) branch expands to an ok expression. mod checke...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 ln(x: f64) -> MathResult { if x <....0 { Err(MathError::NonPositiveLogarithm) } else { Ok(x.ln()) } } // Intermediate function fn op_(x: f64... - https://man.plustar.jp/rust/example/std/result/question_mark.html - [similar]
- Tests - Rust By Example 日本語版 9698
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...d3b32b97275ec472 running 3 tests test test_bar ... ok test test_baz ... ok test test_foo_bar ... ok test...test_foo ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0...d3b32b97275ec472 running 2 tests test test_foo ... ok test test_foo_bar ... ok test result: ok. 2 passed... - https://man.plustar.jp/rust/example/cargo/test.html - [similar]
- ファイルシステムとのやり取り - Rust By Example 日本語版 9506
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...= String::new(); match f.read_to_string(&mut s) { Ok(_) => Ok(s), Err(e) => Err(e), } } // A simple imp...tions::new().create(true).write(true).open(path) { Ok(_) => Ok(()), Err(e) => Err(e), } } fn main() { pr..."a") { Err(why) => println!("! {:?}", why.kind()), Ok(_) => {}, } println!("`echo hello > a/b.txt`"); //...t")) { Err(why) => println!("! {:?}", why.kind()), Ok(s) => println!("> {}", s), } println!("`ls a`"); /... - https://man.plustar.jp/rust/example/std_misc/fs.html - [similar]
- Documentation testing - Rust By Example 日本語版 9426
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...o test : $ cargo test running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filt...running 3 tests test src/lib.rs - add (line 7) ... ok test src/lib.rs - div (line 21) ... ok test src/li...b.rs - div (line 31) ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0...n in doc /// let res = try::try_div(10, 2)?; /// # Ok(()) // returning from try_main /// # } /// # fn ma... - https://man.plustar.jp/rust/example/testing/doc_testing.html - [similar]
- Integration testing - Rust By Example 日本語版 8611
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...s of your library work correctly together. Cargo looks for integration tests in tests directory next to...command: $ cargo test running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filt...-bcd60824f5fbfe19 running 1 test test test_add ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0...d out Doc-tests adder running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filt... - https://man.plustar.jp/rust/example/testing/integration_testing.html - [similar]
- Resultのmap - Rust By Example 日本語版 8420
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...ntError> { match first_number_str.parse::<i32>() { Ok(first_number) => { match second_number_str.parse::...<i32>() { Ok(second_number) => { Ok(first_number * second_numbe...sult: Result<i32, ParseIntError>) { match result { Ok(n) => println!("n is {}", n), Err(e) => println!("...sult: Result<i32, ParseIntError>) { match result { Ok(n) => println!("n is {}", n), Err(e) => println!("... - https://man.plustar.jp/rust/example/error/result/result_map.html - [similar]
- 早期リターン - Rust By Example 日本語版 8148
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...t_number = match first_number_str.parse::<i32>() { Ok(first_number) => first_number, Err(e) => return Er..._number = match second_number_str.parse::<i32>() { Ok(second_number) => second_number, Err(e) => return...Err(e), }; Ok(first_number * second_number) } fn print(result: R...esult<i32, ParseIntError>) { match result { Ok(n) => println!("n is {}", n), Err(e) => println!("... - https://man.plustar.jp/rust/example/error/result/early_returns.html - [similar]
- ?の導入 - Rust By Example 日本語版 8068
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...second_number = second_number_str.parse::<i32>()?; Ok(first_number * second_number) } fn print(result: R...esult<i32, ParseIntError>) { match result { Ok(n) => println!("n is {}", n), Err(e) => println!("...d_number = try!(second_number_str.parse::<i32>()); Ok(first_number * second_number) } fn print(result: R...esult<i32, ParseIntError>) { match result { Ok(n) => println!("n is {}", n), Err(e) => println!("... - https://man.plustar.jp/rust/example/error/result/enter_question_mark.html - [similar]