Skip to content

Commit 4079bba

Browse files
authored
Merge pull request #140 from kdnakt/translate-mod-visibility
Translate untranslated lines in visibility.md
2 parents 000c939 + 04221f0 commit 4079bba

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/mod/visibility.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ mod my_mod {
3535
}
3636
3737
// Modules can also be nested
38+
// モジュールもネストできる
3839
pub mod nested {
3940
pub fn function() {
4041
println!("called `my_mod::nested::function()`");
@@ -47,19 +48,24 @@ mod my_mod {
4748
4849
// Functions declared using `pub(in path)` syntax are only visible
4950
// within the given path. `path` must be a parent or ancestor module
51+
// `pub(in path)`形式で宣言された関数は該当のパス内でのみアクセスできる。
52+
// `path`は親や先祖のモジュールでなくてはならない。
5053
pub(in crate::my_mod) fn public_function_in_my_mod() {
5154
print!("called `my_mod::nested::public_function_in_my_mod()`, that\n> ");
5255
public_function_in_nested();
5356
}
5457
5558
// Functions declared using `pub(self)` syntax are only visible within
5659
// the current module, which is the same as leaving them private
60+
// `pub(self)`形式で宣言された関数は現在のモジュール内でのみアクセスできる。
61+
// つまり、プライベートにするのと同じである。
5762
pub(self) fn public_function_in_nested() {
5863
println!("called `my_mod::nested::public_function_in_nested()`");
5964
}
6065
6166
// Functions declared using `pub(super)` syntax are only visible within
6267
// the parent module
68+
// `pub(super)`形式で宣言された関数は親モジュール内でのみアクセスできる。
6369
pub(super) fn public_function_in_super_mod() {
6470
println!("called `my_mod::nested::public_function_in_super_mod()`");
6571
}
@@ -73,6 +79,7 @@ mod my_mod {
7379
}
7480
7581
// pub(crate) makes functions visible only within the current crate
82+
// pub(crate)により関数は現在のクレート内でのみアクセスできる。
7683
pub(crate) fn public_function_in_crate() {
7784
println!("called `my_mod::public_function_in_crate()`");
7885
}
@@ -87,6 +94,8 @@ mod my_mod {
8794
8895
// Private parent items will still restrict the visibility of a child item,
8996
// even if it is declared as visible within a bigger scope.
97+
// 親がプライベートな場合、子要素がより大きなスコープでアクセスできるように宣言されていても、
98+
// 子要素にアクセス可能な範囲は制限されます。
9099
#[allow(dead_code)]
91100
pub(crate) fn restricted_function() {
92101
println!("called `my_mod::private_nested::restricted_function()`");
@@ -113,12 +122,16 @@ fn main() {
113122
my_mod::call_public_function_in_my_mod();
114123
115124
// pub(crate) items can be called from anywhere in the same crate
125+
// pub(crate)の要素は同じクレートのどこからでも呼び出すことができる。
116126
my_mod::public_function_in_crate();
117127
118128
// pub(in path) items can only be called from within the module specified
119129
// Error! function `public_function_in_my_mod` is private
130+
// pub(in path)の要素は指定されたモジュールからのみ呼び出すことができる。
131+
// エラー! `public_function_in_my_mod`関数はプライベート。
120132
//my_mod::nested::public_function_in_my_mod();
121133
// TODO ^ Try uncommenting this line
134+
// TODO ^ 試しにこの行をアンコメントしてみましょう。
122135
123136
// Private items of a module cannot be directly accessed, even if
124137
// nested in a public module:
@@ -138,13 +151,15 @@ fn main() {
138151
// TODO ^ 試しにこの行をアンコメントしてみましょう。
139152
140153
// Error! `private_nested` is a private module
141-
// エラー!`private_nested`はプライベートなモジュール
154+
// エラー!`private_nested`はプライベートなモジュール。
142155
//my_mod::private_nested::function();
143156
// TODO ^ Try uncommenting this line
144157
// TODO ^ 試しにこの行をアンコメントしてみましょう。
145158
146159
// Error! `private_nested` is a private module
160+
// エラー! `private_nested`はプライベートなモジュール。
147161
//my_mod::private_nested::restricted_function();
148162
// TODO ^ Try uncommenting this line
163+
// TODO ^ 試しにこの行をアンコメントしてみましょう。
149164
}
150165
```

0 commit comments

Comments
 (0)