@@ -78,11 +78,11 @@ let y = x;
78
78
<!-- ## `*const T` and `*mut T`-->
79
79
## ` *const T ` と ` *mut T `
80
80
81
- <!-- These are C-like raw pointers with no lifetime or ownership attached to them. They just point to-->
81
+ <!-- These are C-like raw pointers with no lifetime or ownership attached to them. They point to -->
82
82
<!-- some location in memory with no other restrictions. The only guarantee that these provide is that-->
83
83
<!-- they cannot be dereferenced except in code marked `unsafe`.-->
84
84
関連付けられたライフタイムや所有権を持たない、C的な生ポインタがあります。
85
- それらはメモリのある場所を何の制約もなく単に指示します 。
85
+ それらはメモリのある場所を何の制約もなく指示します 。
86
86
それらの提供する唯一の保証は、 ` unsafe ` であるとマークされたコードの外ではそれらが参照を外せないということです。
87
87
88
88
<!-- These are useful when building safe, low cost abstractions like `Vec<T>`, but should be avoided in-->
@@ -284,7 +284,7 @@ let x = RefCell::new(vec![1,2,3,4]);
284
284
一般的に、そのような変更はネストした形式では発生しないと考えられますが、それをチェックすることはよいことです。
285
285
286
286
<!-- For large, complicated programs, it becomes useful to put some things in `RefCell`s to make things-->
287
- <!-- simpler. For example, a lot of the maps in [ the `ctxt` struct][ctxt] in the Rust compiler internals-->
287
+ <!-- simpler. For example, a lot of the maps in the `ctxt` struct in the Rust compiler internals -->
288
288
<!-- are inside this wrapper. These are only modified once (during creation, which is not right after-->
289
289
<!-- initialization) or a couple of times in well-separated places. However, since this struct is-->
290
290
<!-- pervasively used everywhere, juggling mutable and immutable pointers would be hard (perhaps-->
@@ -293,7 +293,7 @@ let x = RefCell::new(vec![1,2,3,4]);
293
293
<!-- someone adds some code that attempts to modify the cell when it's already borrowed, it will cause a-->
294
294
<!-- (usually deterministic) panic which can be traced back to the offending borrow.-->
295
295
大きく複雑なプログラムにとって、物事を単純にするために何かを ` RefCell ` の中に入れることは便利です。
296
- 例えば、Rustコンパイラの内部の [ ` ctxt ` 構造体 ] [ ctxt ] にあるたくさんのマップはこのラッパの中にあります 。
296
+ 例えば、Rustコンパイラの内部の` ctxt ` 構造体にあるたくさんのマップはこのラッパの中にあります 。
297
297
それらは(初期化の直後ではなく生成の過程で)一度だけ変更されるか、又はきれいに分離された場所で数回変更されます。
298
298
しかし、この構造体はあらゆる場所で全般的に使われているので、ミュータブルなポインタとイミュータブルなポインタとをジャグリング的に扱うのは難しく(あるいは不可能で)、おそらく拡張の困難な ` & ` ポインタのスープになってしまいます。
299
299
一方、 ` RefCell ` はそれらにアクセスするための(ゼロコストではありませんが)低コストの方法です。
@@ -330,7 +330,6 @@ let x = RefCell::new(vec![1,2,3,4]);
330
330
[ cell-mod ] : ../std/cell/
331
331
[ cell ] : ../std/cell/struct.Cell.html
332
332
[ refcell ] : ../std/cell/struct.RefCell.html
333
- [ ctxt ] : ../rustc/middle/ty/struct.ctxt.html
334
333
335
334
<!-- # Synchronous types-->
336
335
# 同期型
@@ -358,7 +357,7 @@ let x = RefCell::new(vec![1,2,3,4]);
358
357
359
358
## ` Arc<T> `
360
359
361
- <!-- [`Arc<T>`][arc] is just a version of `Rc<T>` that uses an atomic reference count (hence, "Arc").-->
360
+ <!-- [`Arc<T>`][arc] is a version of `Rc<T>` that uses an atomic reference count (hence, "Arc"). -->
362
361
<!-- This can be sent freely between threads.-->
363
362
[ ` Arc<T> ` ] [ arc ] はアトミックな参照カウントを使う ` Rc<T> ` の別バージョンです(そのため、「Arc」なのです)。
364
363
これはスレッド間で自由に送ることができます。
@@ -479,7 +478,7 @@ Rustのコードを読むときに一般的な悩みは、 `Rc<RefCell<Vec<T>>>`
479
478
<!-- mutable. At the same time, there can only be one mutable borrow of the whole `Vec` at a given time.-->
480
479
<!-- This means that your code cannot simultaneously work on different elements of the vector from-->
481
480
<!-- different `Rc` handles. However, we are able to push and pop from the `Vec<T>` at will. This is-->
482
- <!-- similar to an `&mut Vec<T>` with the borrow checking done at runtime.-->
481
+ <!-- similar to a `&mut Vec<T>` with the borrow checking done at runtime. -->
483
482
1つ目について、 ` RefCell<T> ` は ` Vec<T> ` をラップしているので、その ` Vec<T> ` 全体がミュータブルです。
484
483
同時に、それらは特定の時間において ` Vec ` 全体の唯一のミュータブルな借用になり得ます。
485
484
これは、コードがそのベクタの別の要素について、別の ` Rc ` ハンドルから同時には操作できないということを意味します。
@@ -488,7 +487,7 @@ Rustのコードを読むときに一般的な悩みは、 `Rc<RefCell<Vec<T>>>`
488
487
489
488
<!-- With the latter, the borrowing is of individual elements, but the overall vector is immutable. Thus,-->
490
489
<!-- we can independently borrow separate elements, but we cannot push or pop from the vector. This is-->
491
- <!-- similar to an `&mut [T]`[^3], but, again, the borrow checking is at runtime.-->
490
+ <!-- similar to a `&mut [T]`[^3], but, again, the borrow checking is at runtime. -->
492
491
2つ目について、借用は個々の要素に対して行われますが、ベクタ全体がイミュータブルになります。
493
492
そのため、異なる要素を別々に借用することができますが、ベクタに対するプッシュやポップを行うことはできません。
494
493
これは ` &mut [T] ` [ ^ 3 ] と同じですが、やはり借用チェックは実行時に行われます。
0 commit comments