@@ -14,7 +14,7 @@ Rustでは、ジェネリクスを用いてこれを実現しています。
1414<!-- Anyway, enough type theory, let’s check out some generic code. Rust’s -->
1515<!-- standard library provides a type, `Option<T>`, that’s generic: -->
1616さて、型理論はもう十分です。
17- 続いてジェネリックなコードを幾つか見ていきましょう 。
17+ 続いてジェネリックなコードをいくつか見ていきましょう 。
1818Rustが標準ライブラリで提供している型 ` Option<T> ` はジェネリックです。
1919
2020``` rust
@@ -54,10 +54,10 @@ let x: Option<f64> = Some(5);
5454// found `core::option::Option<_>` (expected f64 but found integral variable)
5555```
5656
57- <!-- That doesn’t mean we can’t make `Option<T>`s that hold an `f64`! They just have -->
57+ <!-- That doesn’t mean we can’t make `Option<T>`s that hold an `f64`! They have -->
5858<!-- to match up: -->
5959これは ` f64 ` を保持する ` Option<T> ` が作れないという意味ではありませんからね!
60- リテラルと宣言の型をぴったり合わせなければなりません 。
60+ リテラルと宣言の型を合わせなければなりません 。
6161
6262``` rust
6363let x : Option <i32 > = Some (5 );
@@ -66,7 +66,7 @@ let y: Option<f64> = Some(5.0f64);
6666
6767<!-- This is just fine. One definition, multiple uses. -->
6868これだけで結構です。
69- 1つの定義で、多くの用途が得られます 。
69+ 1つの定義で、多くの用途に対応できます 。
7070
7171<!-- Generics don’t have to only be generic over one type. Consider another type from Rust’s standard library that’s similar, `Result<T, E>`: -->
7272ジェネリクスにおいてジェネリックな型は1つまで、といった制限はありません。
@@ -157,9 +157,9 @@ let float_origin = Point { x: 0.0, y: 0.0 };
157157<!-- and we then use `x: T` in the type declaration, too. -->
158158関数と同様に、 ` <T> ` がジェネリックパラメータを宣言する場所であり、型宣言において ` x: T ` を使うのも同じです。
159159
160- <!-- When you want to add an implementation for the generic `struct`, you just -->
160+ <!-- When you want to add an implementation for the generic `struct`, you -->
161161<!-- declare the type parameter after the `impl`: -->
162- ジェネリックな ` struct ` に実装を追加したい場合、 ` impl ` の後に型パラメータを宣言するだけです 。
162+ ジェネリックな ` struct ` に実装を追加したい場合、 ` impl ` の後に型パラメータを宣言します 。
163163
164164``` rust
165165# struct Point <T > {
0 commit comments