検索

phrase: max: clip:
target: order:
Results of 1 - 10 of about 12 for NUM (0.025 sec.)
スタティックライフタイム - Rust By Example 日本語版 14486
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... e. // `'static`ライフタイムを持つ定数を作成 static NUM: i32 = 18; // Returns a reference to `NUM` where i ... time is coerced to that of the input argument. // `NUM`への参照を返す。ライフタイムは`'static`から引数の ... る。 fn coerce_static<'a>(_: &'a i32) -> &'a i32 { &NUM } fn main() { { // Make a `string` literal and pri ... atic`関数を呼び出すために、整数を作成 let lifetime_num = 9; // Coerce `NUM` to lifetime of `lifetime_num` ...
https://man.plustar.jp/rust/example/scope/lifetime/static_lifetime.html - [similar]
FromおよびInto - Rust By Example 日本語版 9586
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... す。 use std::convert::From; #[derive(Debug)] struct Number { value: i32, } impl From<i32> for Number { fn ... from(item: i32) -> Self { Number { value: item } } } fn main() { let num = Numbe ... r::from(30); println!("My number is {:?}", num); } Into Into トレイトは、単に Fr ... す。 use std::convert::From; #[derive(Debug)] struct Number { value: i32, } impl From<i32> for Number { fn ...
https://man.plustar.jp/rust/example/conversion/from_into.html - [similar]
OptionからResultを取り出す - Rust By Example 日本語版 8525
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... は、単にお互いを埋め込んでしまうことです。 use std::num::ParseIntError; fn double_first(vec: Vec<&str>) -> ... parse::<i32>().map(|n| 2 * n) }) } fn main() { let numbers = vec!["42", "93", "18"]; let empty = vec![]; ... println!("The first doubled is {:?}", double_first(numbers)); println!("The first doubled is {:?}", doubl ... ings)); // Error 2: the element doesn't parse to a number // エラー2:要素が数字としてパースできない } 中に ...
https://man.plustar.jp/rust/example/error/multiple_error_types/option_result.htm... - [similar]
構造体 - Rust By Example 日本語版 8525
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... medBorrowed<'a> { x: &'a i32, y: &'a i32, } // An enum which is either an `i32` or a reference to one. // ... 2`への参照のいずれかとなる列挙型 #[derive(Debug)] enum Either<'a> { Num(i32), Ref(&'a i32), } fn main() { ... &x, y: &y }; let reference = Either::Ref(&x); let number = Either::Num(y); println!("x is borrowed in {: ... eference); println!("y is *not* borrowed in {:?}", number); } 参照 struct s 関連キーワード: 関数 , let , ...
https://man.plustar.jp/rust/example/scope/lifetime/struct.html - [similar]
引数のパース - Rust By Example 日本語版 8525
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... 単な引数をパースできます。 use std::env; fn increase(number: i32) { println!("{}", number + 1); } fn decrea ... se(number: i32) { println!("{}", number - 1); } fn help() ... つと引数が一つの場合 3 => { let cmd = &args[1]; let num = &args[2]; // parse the number // 数字をパース le ... t number: i32 = match num.parse() { Ok(n) => { n }, Err( ...
https://man.plustar.jp/rust/example/std_misc/arg/matching.html - [similar]
?の導入 - Rust By Example 日本語版 8419
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... 例をどれだけ簡潔に書けるか見てみましょう。 use std::num::ParseIntError; fn multiply(first_number_str: &str ... , second_number_str: &str) -> Result<i32, ParseIntError> { let ... first_number = first_number_str.parse::<i32>()?; let second_ ... number = second_number_str.parse::<i32>()?; Ok(first_number * second_n ...
https://man.plustar.jp/rust/example/error/result/enter_question_mark.html - [similar]
Resultのmap - Rust By Example 日本語版 8419
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... が全体として扱いづらいコードにしています。 use std::num::ParseIntError; // With the return type rewritten, ... チングを`unwrap()`なしで行います。 fn multiply(first_number_str: &str, second_number_str: &str) -> Result<i ... 32, ParseIntError> { match first_number_str.parse::<i32>() { Ok(first_number) => { matc ... h second_number_str.parse::<i32>() { Ok(second_number) => { Ok( ...
https://man.plustar.jp/rust/example/error/result/result_map.html - [similar]
早期リターン - Rust By Example 日本語版 7941
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... の例の新たなバージョンを考えてみましょう。 use std::num::ParseIntError; fn multiply(first_number_str: &str ... , second_number_str: &str) -> Result<i32, ParseIntError> { let ... first_number = match first_number_str.parse::<i32>() { Ok(fi ... rst_number) => first_number, Err(e) => return Err(e), }; l ...
https://man.plustar.jp/rust/example/error/result/early_returns.html - [similar]
Resultに対するエイリアス - Rust By Example 日本語版 7941
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... なのです! 簡単な例で構文を見てみましょう。 use std::num::ParseIntError; // Define a generic alias for a `R ... (この場所特有の`Result`型)を使用 fn multiply(first_number_str: &str, second_number_str: &str) -> AliasedR ... esult<i32> { first_number_str.parse::<i32>().and_then(|first_number| { se ... cond_number_str.parse::<i32>().map(|second_number| first_nu ...
https://man.plustar.jp/rust/example/error/result/result_alias.html - [similar]
Rust By Example 日本語版 7941
Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2. ... ータ型について学びましょう。 カスタム型 - struct と enum について。 変数の束縛 - ミュータブルな束縛、スコー ... ange what type 31 is // by providing a suffix. The number 31i64 for example has the type i64. // サフィッ ... うに、5つの半角空白のあとに"1"が入ります. println!("{number:>width$}", number=1, width=6); // You can pad n ... このアウトプットは "000001" になります. println!("{number:0>width$}", number=1, width=6); // Rust even ch ...
https://man.plustar.jp/rust/example/print.html - [similar]
PREV 1 2 NEXT