Skip to content

Commit 35839b7

Browse files
committed
reflect a review
1 parent d1cbb34 commit 35839b7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

1.6/ja/book/trait-objects.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Foo for String {
4141
## 静的ディスパッチ
4242

4343
<!-- We can use this trait to perform static dispatch with trait bounds: -->
44-
トレイト境界による静的ディスパッチを実現するためにこのトレイトを使うことができます
44+
トレイト境界を使ってこのトレイトで静的ディスパッチが出来ます
4545

4646
```rust
4747
# trait Foo { fn method(&self) -> String; }
@@ -64,7 +64,7 @@ fn main() {
6464
Rust will create a special version of `do_something()` for both `u8` and
6565
`String`, and then replace the call sites with calls to these specialized
6666
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)と呼ばれます)
6868

6969
```rust
7070
# trait Foo { fn method(&self) -> String; }
@@ -257,7 +257,7 @@ struct FooVtable {
257257
fn call_method_on_u8(x: *const ()) -> String {
258258
# // // the compiler guarantees that this function is only called
259259
# // // with `x` pointing to a u8
260-
// `x` がu8を指しているとき、コンパイラはこの関数だけが呼び出されることを保証します
260+
// コンパイラは `x` がu8を指しているときにのみこの関数が呼ばれることを保障します
261261
let byte: &u8 = unsafe { &*(x as *const u8) };
262262
263263
byte.method()
@@ -280,7 +280,7 @@ static Foo_for_u8_vtable: FooVtable = FooVtable {
280280
fn call_method_on_String(x: *const ()) -> String {
281281
# // // the compiler guarantees that this function is only called
282282
# // // with `x` pointing to a String
283-
// `x`がStringを指しているとき、コンパイラはこの関数だけが呼ばれることを保証します
283+
// コンパイラは `x` がStringを指しているときにのみこの関数が呼ばれることを保障します
284284
let string: &String = unsafe { &*(x as *const String) };
285285
286286
string.method()
@@ -290,7 +290,7 @@ static Foo_for_String_vtable: FooVtable = FooVtable {
290290
# // destructor: /* compiler magic */,
291291
destructor: /* コンパイラマジック */,
292292
# // // values for a 64-bit computer, halve them for 32-bit ones
293-
// 64-bitコンピュータの値を、32-bitコンピュータ向けに半分にしておく
293+
// この値は64bitコンピュータ向けのものです、32bitコンピュータではこの半分にします
294294
size: 24,
295295
align: 8,
296296
@@ -312,7 +312,7 @@ made more flexible. -->
312312
<!-- Suppose we’ve got some values that implement `Foo`. The explicit form of
313313
construction and use of `Foo` trait objects might look a bit like (ignoring the
314314
type mismatches: they’re all just pointers anyway): -->
315-
仮に `Foo` を実装する値を幾つか得たとします。構文による明示的な形式とこれまでに紹介した `Foo` トレイトオブジェクトの用法は少しだけ似ているかもしれません。(とにかく全てポインタにすることで型の不一致を無視しています)
315+
例えば `Foo` を実装する値を幾つか得たとします。 `Foo` トレイトオブジェクトを作る、あるいは使う時のコードを明示的に書いたものは少しだけ似ているでしょう。(型の違いを無視すればですが。どのみちただのポインタになります)
316316

317317
```rust,ignore
318318
let a: String = "foo".to_string();

0 commit comments

Comments
 (0)