@@ -14,7 +14,7 @@ Rustでは、ジェネリクスを用いてこれを実現しています。
14
14
<!-- Anyway, enough type theory, let’s check out some generic code. Rust’s -->
15
15
<!-- standard library provides a type, `Option<T>`, that’s generic: -->
16
16
さて、型理論はもう十分です。
17
- 続いてジェネリックなコードを幾つか見ていきましょう 。
17
+ 続いてジェネリックなコードをいくつか見ていきましょう 。
18
18
Rustが標準ライブラリで提供している型 ` Option<T> ` はジェネリックです。
19
19
20
20
``` rust
@@ -54,10 +54,10 @@ let x: Option<f64> = Some(5);
54
54
// found `core::option::Option<_>` (expected f64 but found integral variable)
55
55
```
56
56
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 -->
58
58
<!-- to match up: -->
59
59
これは ` f64 ` を保持する ` Option<T> ` が作れないという意味ではありませんからね!
60
- リテラルと宣言の型をぴったり合わせなければなりません 。
60
+ リテラルと宣言の型を合わせなければなりません 。
61
61
62
62
``` rust
63
63
let x : Option <i32 > = Some (5 );
@@ -66,7 +66,7 @@ let y: Option<f64> = Some(5.0f64);
66
66
67
67
<!-- This is just fine. One definition, multiple uses. -->
68
68
これだけで結構です。
69
- 1つの定義で、多くの用途が得られます 。
69
+ 1つの定義で、多くの用途に対応できます 。
70
70
71
71
<!-- 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>`: -->
72
72
ジェネリクスにおいてジェネリックな型は1つまで、といった制限はありません。
@@ -157,9 +157,9 @@ let float_origin = Point { x: 0.0, y: 0.0 };
157
157
<!-- and we then use `x: T` in the type declaration, too. -->
158
158
関数と同様に、 ` <T> ` がジェネリックパラメータを宣言する場所であり、型宣言において ` x: T ` を使うのも同じです。
159
159
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 -->
161
161
<!-- declare the type parameter after the `impl`: -->
162
- ジェネリックな ` struct ` に実装を追加したい場合、 ` impl ` の後に型パラメータを宣言するだけです 。
162
+ ジェネリックな ` struct ` に実装を追加したい場合、 ` impl ` の後に型パラメータを宣言します 。
163
163
164
164
``` rust
165
165
# struct Point <T > {
0 commit comments