@@ -178,23 +178,23 @@ <h1><a class="header" href="#動的サイズの型dst-dynamically-sized-type" id
178
178
<!--
179
179
There are two major DSTs exposed by the language: trait objects, and slices.
180
180
-->
181
- < p > 言語が提供する DST のうち重要なものが 2 つあります。trait オブジェクトとスライスです 。</ p >
181
+ < p > 言語が提供する DST のうち重要なものが 2 つあります。トレイトオブジェクトとスライスです 。</ p >
182
182
<!--
183
183
A trait object represents some type that implements the traits it specifies.
184
184
The exact original type is *erased* in favor of runtime reflection
185
185
with a vtable containing all the information necessary to use the type.
186
186
This is the information that completes a trait object: a pointer to its vtable.
187
187
-->
188
- < p > Trait オブジェクトは、それが指す Trait を実装するある型を表現します 。
188
+ < p > トレイトオブジェクトは、それが指すトレイトを実装するある型を表現します 。
189
189
元となった型は消去されますが、vtable とリフレクションとによって実行時にはその型を利用することができます。
190
190
つまり、Trait オブジェクトを補完する情報とは vtable へのポインタとなります。</ p >
191
191
<!--
192
192
A slice is simply a view into some contiguous storage -- typically an array or
193
193
`Vec`. The information that completes a slice is just the number of elements
194
194
it points to.
195
195
-->
196
- < p > スライスとは、単純にある連続したスペース(通常はアレイか < code > Vec</ code > )のビューです。
197
- スライスを補完する情報とは、単にポインタが指すエレメントの数です 。</ p >
196
+ < p > スライスとは、単純にある連続したスペース(通常は配列か < code > Vec</ code > )のビューです。
197
+ スライスを補完する情報とは、単にポインタが指す要素の数です 。</ p >
198
198
<!--
199
199
Structs can actually store a single DST directly as their last field, but this
200
200
makes them a DST as well:
@@ -231,8 +231,8 @@ <h1><a class="header" href="#サイズが-0-の型zst-zero-sized-type" id="サ
231
231
// すべてのフィールドのサイズがない = サイズ 0
232
232
struct Baz {
233
233
foo: Foo,
234
- qux: (), // empty tuple has no size
235
- baz: [u8; 0], // empty array has no size
234
+ qux: (), // 空のタプルにはサイズがありません
235
+ baz: [u8; 0], // 空の配列にはサイズがありません
236
236
}
237
237
#}</ code > </ pre > </ pre >
238
238
<!--
@@ -244,7 +244,7 @@ <h1><a class="header" href="#サイズが-0-の型zst-zero-sized-type" id="サ
244
244
type, so anything that loads it can just produce it from the aether -- which is
245
245
also a no-op since it doesn't occupy any space.
246
246
-->
247
- < p > サイズ 0 の型(ZST)は、当然ながら、それ自体ではほとんど価値があありません 。
247
+ < p > サイズ 0 の型(ZST)は、当然ながら、それ自体ではほとんど価値がありません 。
248
248
しかし、多くの興味深いレイアウトの選択肢と組み合わせると、ZST が潜在的に役に立つことがいろいろな
249
249
ケースで明らかになります。Rust は、ZST を生成したり保存したりするオペレーションが no-op に
250
250
還元できることを理解しています。
@@ -261,7 +261,7 @@ <h1><a class="header" href="#サイズが-0-の型zst-zero-sized-type" id="サ
261
261
-->
262
262
< p > 究極の ZST の利用法として、Set と Map を考えてみましょう。
263
263
< code > Map<Key, Value></ code > があるときに、< code > Set<Key></ code > を < code > Map<Key, UselessJunk></ code > の
264
- 簡単なラッパーとして実装することはよくあります 。
264
+ 簡単なラッパとして実装することはよくあります 。
265
265
多くの言語では、UselessJunk のスペースを割り当てる必要があるでしょうし、
266
266
結果的に使わない UselessJunk を保存したり読み込んだりする必要もあるでしょう。
267
267
こういったことが不要であると示すのはコンパイラにとっては難しい仕事でしょう。</ p >
@@ -283,7 +283,7 @@ <h1><a class="header" href="#サイズが-0-の型zst-zero-sized-type" id="サ
283
283
may return `nullptr` when a zero-sized allocation is requested, which is
284
284
indistinguishable from out of memory.
285
285
-->
286
- < p > 安全なコードは ZST について心配する必要はありませんが、< em > 危険な </ em > コードは
286
+ < p > 安全なコードは ZST について心配する必要はありませんが、< em > アンセーフな </ em > コードは
287
287
サイズ 0 の型を使った時の結果について注意しなくてはなりません。
288
288
特に、ポインタのオフセットは no-op になることや、
289
289
(Rust のデフォルトである jemalloc を含む)標準的なメモリアロケータは、
@@ -321,7 +321,7 @@ <h1><a class="header" href="#空の型" id="空の型">空の型</a></h1>
321
321
特定のケースでは絶対に失敗しないことがわかっているとします。
322
322
< code > Result<T, Void></ code > を返すことで、この事実を型レベルで伝えることが可能です。
323
323
Void 型の値を提供することはできないので、この Result は Err に< em > なり得ないと静的にわかります</ em > 。
324
- そのため、この API の利用者は、自信を持って Result を unwrap することができます 。</ p >
324
+ そのため、この API の利用者は、自信を持って Result をアンラップすることができます 。</ p >
325
325
<!--
326
326
In principle, Rust can do some interesting analyses and optimizations based
327
327
on this fact. For instance, `Result<T, Void>` could be represented as just `T`,
@@ -343,18 +343,18 @@ <h1><a class="header" href="#空の型" id="空の型">空の型</a></h1>
343
343
the ability to be confident that certain situations are statically impossible.
344
344
-->
345
345
< p > ただし、どちらの例も現時点では動きません。
346
- つまり、Void 型による利点は、静的な解析によて 、特定の状況が起こらないと確実に言えることだけです。</ p >
346
+ つまり、Void 型による利点は、静的な解析によって 、特定の状況が起こらないと確実に言えることだけです。</ p >
347
347
<!--
348
348
One final subtle detail about empty types is that raw pointers to them are
349
349
actually valid to construct, but dereferencing them is Undefined Behavior
350
350
because that doesn't actually make sense. That is, you could model C's `void *`
351
351
type with `*const Void`, but this doesn't necessarily gain anything over using
352
352
e.g. `*const ()`, which *is* safe to randomly dereference.
353
353
-->
354
- < p > 最後に細かいことを一つ。空の型を指す生のポインタを構成することは有効ですが 、
355
- それをデリファレンスすることは 、意味がないので、未定義の挙動となります。
354
+ < p > 最後に細かいことを一つ。空の型を指す生ポインタを構成することは有効ですが 、
355
+ それを参照外しすることは 、意味がないので、未定義の挙動となります。
356
356
つまり、C における < code > void *</ code > と同じような意味で < code > *const Void</ code > を使うこと出来ますが、
357
- これは、< em > 安全に</ em > デリファレンスできる型 (例えば < code > *const ()</ code > )と比べて何も利点はありません。</ p >
357
+ これは、< em > 安全に</ em > 参照外しできる型 (例えば < code > *const ()</ code > )と比べて何も利点はありません。</ p >
358
358
359
359
</ main >
360
360
0 commit comments