@@ -41,7 +41,7 @@ impl Foo for String {
41
41
## 静的ディスパッチ
42
42
43
43
<!-- We can use this trait to perform static dispatch with trait bounds: -->
44
- トレイト境界による静的ディスパッチを実現するためにこのトレイトを使うことができます 。
44
+ トレイト境界を使ってこのトレイトで静的ディスパッチが出来ます 。
45
45
46
46
``` rust
47
47
# trait Foo { fn method (& self ) -> String ; }
@@ -64,7 +64,7 @@ fn main() {
64
64
Rust will create a special version of `do_something()` for both `u8` and
65
65
`String`, and then replace the call sites with calls to these specialized
66
66
functions. In other words, Rust generates something like this: -->
67
- Rustはここで静的ディスパッチを実現するため「モノモーフィゼーション」(monomorphization)を用います。 これはRustが ` u8 ` と ` String ` それぞれ専用の ` do_something() ` を作成し、それら専用の関数を宛がうように呼び出しの部分を書き換えるという意味です。言い換えれば、Rustは以下のようなコードを生成します。
67
+ これはRustが ` u8 ` と ` String ` それぞれ専用の ` do_something() ` を作成し、それら特殊化された関数を宛がうように呼び出しの部分を書き換えるという意味です。(訳注: 作成された専用の ` do_something() ` は「特殊化された関数」(specialized function)と呼ばれます)
68
68
69
69
``` rust
70
70
# trait Foo { fn method (& self ) -> String ; }
@@ -257,7 +257,7 @@ struct FooVtable {
257
257
fn call_method_on_u8(x: *const ()) -> String {
258
258
# // // the compiler guarantees that this function is only called
259
259
# // // with `x` pointing to a u8
260
- // `x` がu8を指しているとき、コンパイラはこの関数だけが呼び出されることを保証します
260
+ // コンパイラは `x` がu8を指しているときにのみこの関数が呼ばれることを保障します
261
261
let byte: &u8 = unsafe { &*(x as *const u8) };
262
262
263
263
byte.method()
@@ -280,7 +280,7 @@ static Foo_for_u8_vtable: FooVtable = FooVtable {
280
280
fn call_method_on_String(x: *const ()) -> String {
281
281
# // // the compiler guarantees that this function is only called
282
282
# // // with `x` pointing to a String
283
- // `x`がStringを指しているとき、コンパイラはこの関数だけが呼ばれることを保証します
283
+ // コンパイラは `x` がStringを指しているときにのみこの関数が呼ばれることを保障します
284
284
let string: &String = unsafe { &*(x as *const String) };
285
285
286
286
string.method()
@@ -290,7 +290,7 @@ static Foo_for_String_vtable: FooVtable = FooVtable {
290
290
# // destructor: /* compiler magic */,
291
291
destructor: /* コンパイラマジック */,
292
292
# // // values for a 64-bit computer, halve them for 32-bit ones
293
- // 64-bitコンピュータの値を、32-bitコンピュータ向けに半分にしておく
293
+ // この値は64bitコンピュータ向けのものです、32bitコンピュータではこの半分にします
294
294
size: 24,
295
295
align: 8,
296
296
@@ -312,7 +312,7 @@ made more flexible. -->
312
312
<!-- Suppose we’ve got some values that implement `Foo`. The explicit form of
313
313
construction and use of `Foo` trait objects might look a bit like (ignoring the
314
314
type mismatches: they’re all just pointers anyway): -->
315
- 仮に ` Foo ` を実装する値を幾つか得たとします。構文による明示的な形式とこれまでに紹介した ` Foo ` トレイトオブジェクトの用法は少しだけ似ているかもしれません。(とにかく全てポインタにすることで型の不一致を無視しています)
315
+ 例えば ` Foo ` を実装する値を幾つか得たとします。 ` Foo ` トレイトオブジェクトを作る、あるいは使う時のコードを明示的に書いたものは少しだけ似ているでしょう。(型の違いを無視すればですが。どのみちただのポインタになります)
316
316
317
317
``` rust,ignore
318
318
let a: String = "foo".to_string();
0 commit comments