@@ -78,11 +78,11 @@ let y = x;
7878<!-- ## `*const T` and `*mut T`-->
7979## ` *const T ` と ` *mut T `
8080
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 -->
8282<!-- some location in memory with no other restrictions. The only guarantee that these provide is that-->
8383<!-- they cannot be dereferenced except in code marked `unsafe`.-->
8484関連付けられたライフタイムや所有権を持たない、C的な生ポインタがあります。
85- それらはメモリのある場所を何の制約もなく単に指示します 。
85+ それらはメモリのある場所を何の制約もなく指示します 。
8686それらの提供する唯一の保証は、 ` unsafe ` であるとマークされたコードの外ではそれらが参照を外せないということです。
8787
8888<!-- 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]);
284284一般的に、そのような変更はネストした形式では発生しないと考えられますが、それをチェックすることはよいことです。
285285
286286<!-- 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 -->
288288<!-- are inside this wrapper. These are only modified once (during creation, which is not right after-->
289289<!-- initialization) or a couple of times in well-separated places. However, since this struct is-->
290290<!-- 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]);
293293<!-- someone adds some code that attempts to modify the cell when it's already borrowed, it will cause a-->
294294<!-- (usually deterministic) panic which can be traced back to the offending borrow.-->
295295大きく複雑なプログラムにとって、物事を単純にするために何かを ` RefCell ` の中に入れることは便利です。
296- 例えば、Rustコンパイラの内部の [ ` ctxt ` 構造体 ] [ ctxt ] にあるたくさんのマップはこのラッパの中にあります 。
296+ 例えば、Rustコンパイラの内部の` ctxt ` 構造体にあるたくさんのマップはこのラッパの中にあります 。
297297それらは(初期化の直後ではなく生成の過程で)一度だけ変更されるか、又はきれいに分離された場所で数回変更されます。
298298しかし、この構造体はあらゆる場所で全般的に使われているので、ミュータブルなポインタとイミュータブルなポインタとをジャグリング的に扱うのは難しく(あるいは不可能で)、おそらく拡張の困難な ` & ` ポインタのスープになってしまいます。
299299一方、 ` RefCell ` はそれらにアクセスするための(ゼロコストではありませんが)低コストの方法です。
@@ -330,7 +330,6 @@ let x = RefCell::new(vec![1,2,3,4]);
330330[ cell-mod ] : ../std/cell/
331331[ cell ] : ../std/cell/struct.Cell.html
332332[ refcell ] : ../std/cell/struct.RefCell.html
333- [ ctxt ] : ../rustc/middle/ty/struct.ctxt.html
334333
335334<!-- # Synchronous types-->
336335# 同期型
@@ -358,7 +357,7 @@ let x = RefCell::new(vec![1,2,3,4]);
358357
359358## ` Arc<T> `
360359
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"). -->
362361<!-- This can be sent freely between threads.-->
363362[ ` Arc<T> ` ] [ arc ] はアトミックな参照カウントを使う ` Rc<T> ` の別バージョンです(そのため、「Arc」なのです)。
364363これはスレッド間で自由に送ることができます。
@@ -479,7 +478,7 @@ Rustのコードを読むときに一般的な悩みは、 `Rc<RefCell<Vec<T>>>`
479478<!-- mutable. At the same time, there can only be one mutable borrow of the whole `Vec` at a given time.-->
480479<!-- This means that your code cannot simultaneously work on different elements of the vector from-->
481480<!-- 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. -->
4834821つ目について、 ` RefCell<T> ` は ` Vec<T> ` をラップしているので、その ` Vec<T> ` 全体がミュータブルです。
484483同時に、それらは特定の時間において ` Vec ` 全体の唯一のミュータブルな借用になり得ます。
485484これは、コードがそのベクタの別の要素について、別の ` Rc ` ハンドルから同時には操作できないということを意味します。
@@ -488,7 +487,7 @@ Rustのコードを読むときに一般的な悩みは、 `Rc<RefCell<Vec<T>>>`
488487
489488<!-- With the latter, the borrowing is of individual elements, but the overall vector is immutable. Thus,-->
490489<!-- 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. -->
4924912つ目について、借用は個々の要素に対して行われますが、ベクタ全体がイミュータブルになります。
493492そのため、異なる要素を別々に借用することができますが、ベクタに対するプッシュやポップを行うことはできません。
494493これは ` &mut [T] ` [ ^ 3 ] と同じですが、やはり借用チェックは実行時に行われます。
0 commit comments