@@ -1211,8 +1211,12 @@ <h1 id="リテラルとオペレータ"><a class="header" href="#リテラルと
1211
1211
`1_000` is the same as `1000`, and `0.000_001` is the same as `0.000001`.
1212
1212
-->
1213
1213
<p>可読性のため、<code>_</code>(アンダースコア)を数値リテラルの間に挿入することができます。例えば<code>1_000</code>は<code>1000</code>と、<code>0.000_001</code>は<code>0.000001</code>とそれぞれ同一です。</p>
1214
- <p>Rust also supports scientific <a href="https://en.wikipedia.org/wiki/Scientific_notation#E_notation">E-notation</a>, e.g. <code>1e6</code>, <code>7.6e-4</code>. The
1215
- associated type is <code>f64</code>.</p>
1214
+ <!--
1215
+ Rust also supports scientific [E-notation][enote], e.g. `1e6`, `7.6e-4`. The
1216
+ associated type is `f64`.
1217
+ -->
1218
+ <p>また、Rustは<code>1e6</code>や<code>7.6e-4</code>などの科学的な<a href="https://en.wikipedia.org/wiki/Scientific_notation#E_notation">E表記</a>をサポートしています。
1219
+ 関連型は<code>f64</code>です。</p>
1216
1220
<!--
1217
1221
We need to tell the compiler the type of the literals we use. For now,
1218
1222
we'll use the `u32` suffix to indicate that the literal is an unsigned 32-bit
@@ -1236,6 +1240,7 @@ <h1 id="リテラルとオペレータ"><a class="header" href="#リテラルと
1236
1240
// TODO ^ 型が重要であることを実感するため`1i32`を`1u32`に変更してみましょう。
1237
1241
1238
1242
// Scientific notation
1243
+ // 科学的表記
1239
1244
println!("1e4 is {}, -2.5e-3 is {}", 1e4, -2.5e-3);
1240
1245
1241
1246
// Short-circuiting boolean logic
@@ -4859,6 +4864,7 @@ <h1 id="プライベートとパブリック"><a class="header" href="#プライ
4859
4864
}
4860
4865
4861
4866
// Modules can also be nested
4867
+ // モジュールもネストできる
4862
4868
pub mod nested {
4863
4869
pub fn function() {
4864
4870
println!("called `my_mod::nested::function()`");
@@ -4871,19 +4877,24 @@ <h1 id="プライベートとパブリック"><a class="header" href="#プライ
4871
4877
4872
4878
// Functions declared using `pub(in path)` syntax are only visible
4873
4879
// within the given path. `path` must be a parent or ancestor module
4880
+ // `pub(in path)`形式で宣言された関数は該当のパス内でのみアクセスできる。
4881
+ // `path`は親や先祖のモジュールでなくてはならない。
4874
4882
pub(in crate::my_mod) fn public_function_in_my_mod() {
4875
4883
print!("called `my_mod::nested::public_function_in_my_mod()`, that\n> ");
4876
4884
public_function_in_nested();
4877
4885
}
4878
4886
4879
4887
// Functions declared using `pub(self)` syntax are only visible within
4880
4888
// the current module, which is the same as leaving them private
4889
+ // `pub(self)`形式で宣言された関数は現在のモジュール内でのみアクセスできる。
4890
+ // つまり、プライベートにするのと同じである。
4881
4891
pub(self) fn public_function_in_nested() {
4882
4892
println!("called `my_mod::nested::public_function_in_nested()`");
4883
4893
}
4884
4894
4885
4895
// Functions declared using `pub(super)` syntax are only visible within
4886
4896
// the parent module
4897
+ // `pub(super)`形式で宣言された関数は親モジュール内でのみアクセスできる。
4887
4898
pub(super) fn public_function_in_super_mod() {
4888
4899
println!("called `my_mod::nested::public_function_in_super_mod()`");
4889
4900
}
@@ -4897,6 +4908,7 @@ <h1 id="プライベートとパブリック"><a class="header" href="#プライ
4897
4908
}
4898
4909
4899
4910
// pub(crate) makes functions visible only within the current crate
4911
+ // pub(crate)により関数は現在のクレート内でのみアクセスできる。
4900
4912
pub(crate) fn public_function_in_crate() {
4901
4913
println!("called `my_mod::public_function_in_crate()`");
4902
4914
}
@@ -4911,6 +4923,8 @@ <h1 id="プライベートとパブリック"><a class="header" href="#プライ
4911
4923
4912
4924
// Private parent items will still restrict the visibility of a child item,
4913
4925
// even if it is declared as visible within a bigger scope.
4926
+ // 親がプライベートな場合、子要素がより大きなスコープでアクセスできるように宣言されていても、
4927
+ // 子要素にアクセス可能な範囲は制限されます。
4914
4928
#[allow(dead_code)]
4915
4929
pub(crate) fn restricted_function() {
4916
4930
println!("called `my_mod::private_nested::restricted_function()`");
@@ -4937,12 +4951,16 @@ <h1 id="プライベートとパブリック"><a class="header" href="#プライ
4937
4951
my_mod::call_public_function_in_my_mod();
4938
4952
4939
4953
// pub(crate) items can be called from anywhere in the same crate
4954
+ // pub(crate)の要素は同じクレートのどこからでも呼び出すことができる。
4940
4955
my_mod::public_function_in_crate();
4941
4956
4942
4957
// pub(in path) items can only be called from within the module specified
4943
4958
// Error! function `public_function_in_my_mod` is private
4959
+ // pub(in path)の要素は指定されたモジュールからのみ呼び出すことができる。
4960
+ // エラー! `public_function_in_my_mod`関数はプライベート。
4944
4961
//my_mod::nested::public_function_in_my_mod();
4945
4962
// TODO ^ Try uncommenting this line
4963
+ // TODO ^ 試しにこの行をアンコメントしてみましょう。
4946
4964
4947
4965
// Private items of a module cannot be directly accessed, even if
4948
4966
// nested in a public module:
@@ -4962,14 +4980,16 @@ <h1 id="プライベートとパブリック"><a class="header" href="#プライ
4962
4980
// TODO ^ 試しにこの行をアンコメントしてみましょう。
4963
4981
4964
4982
// Error! `private_nested` is a private module
4965
- // エラー!`private_nested`はプライベートなモジュール 。
4983
+ // エラー!`private_nested`はプライベートなモジュール。
4966
4984
//my_mod::private_nested::function();
4967
4985
// TODO ^ Try uncommenting this line
4968
4986
// TODO ^ 試しにこの行をアンコメントしてみましょう。
4969
4987
4970
4988
// Error! `private_nested` is a private module
4989
+ // エラー! `private_nested`はプライベートなモジュール。
4971
4990
//my_mod::private_nested::restricted_function();
4972
4991
// TODO ^ Try uncommenting this line
4992
+ // TODO ^ 試しにこの行をアンコメントしてみましょう。
4973
4993
}</code></pre></pre>
4974
4994
<div style="break-before: page; page-break-before: always;"></div><!--
4975
4995
# Struct visibility
@@ -7445,17 +7465,21 @@ <h1 id="エイリアス-1"><a class="header" href="#エイリアス-1">エイリ
7445
7465
// ミュータブルに借用することができない。
7446
7466
// let mutable_borrow = &mut point;
7447
7467
// TODO ^ Try uncommenting this line
7468
+ // TODO ^ この行をアンコメントしてみましょう。
7448
7469
7449
7470
// The borrowed values are used again here
7471
+ // 借用された値はここで再び利用されます。
7450
7472
println!("Point has coordinates: ({}, {}, {})",
7451
7473
borrowed_point.x, another_borrow.y, point.z);
7452
7474
7453
7475
// The immutable references are no longer used for the rest of the code so
7454
7476
// it is possible to reborrow with a mutable reference.
7477
+ // イミュータブルな参照がこれ以降のコードで利用されていないため、
7478
+ // ミュータブルな参照として再借用できます。
7455
7479
let mutable_borrow = &mut point;
7456
7480
7457
7481
// Change data via mutable reference
7458
- // ミュータブルなリファレンスを介してデータを変更する
7482
+ // ミュータブルな参照を介してデータを変更する
7459
7483
mutable_borrow.x = 5;
7460
7484
mutable_borrow.y = 2;
7461
7485
mutable_borrow.z = 1;
@@ -7469,17 +7493,19 @@ <h1 id="エイリアス-1"><a class="header" href="#エイリアス-1">エイリ
7469
7493
// TODO ^ この行をアンコメントしてみましょう。
7470
7494
7471
7495
// Error! Can't print because `println!` takes an immutable reference.
7472
- // エラー!`println!`はイミュータブルなリファレンスを取るため 、printできません。
7496
+ // エラー!`println!`はイミュータブルな参照を取るため 、printできません。
7473
7497
// println!("Point Z coordinate is {}", point.z);
7474
7498
// TODO ^ Try uncommenting this line
7475
7499
// TODO ^ この行をアンコメントしてみましょう。
7476
7500
7477
7501
// Ok! Mutable references can be passed as immutable to `println!`
7502
+ // OK!ミュータブルな参照は`println!`にイミュータブルな参照として渡せます。
7478
7503
println!("Point has coordinates: ({}, {}, {})",
7479
7504
mutable_borrow.x, mutable_borrow.y, mutable_borrow.z);
7480
7505
7481
7506
// The mutable reference is no longer used for the rest of the code so it
7482
7507
// is possible to reborrow
7508
+ // ミュータブルな参照がこれ以降のコードで利用されていないため、再借用できます。
7483
7509
let new_borrowed_point = &point;
7484
7510
println!("Point now has coordinates: ({}, {}, {})",
7485
7511
new_borrowed_point.x, new_borrowed_point.y, new_borrowed_point.z);
0 commit comments