Skip to content

4.18. Generics (1.9) #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 1.9/ja/book/generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Rustでは、ジェネリクスを用いてこれを実現しています。
<!-- Anyway, enough type theory, let’s check out some generic code. Rust’s -->
<!-- standard library provides a type, `Option<T>`, that’s generic: -->
さて、型理論はもう十分です。
続いてジェネリックなコードを幾つか見ていきましょう
続いてジェネリックなコードをいくつか見ていきましょう
Rustが標準ライブラリで提供している型 `Option<T>` はジェネリックです。

```rust
Expand Down Expand Up @@ -54,10 +54,10 @@ let x: Option<f64> = Some(5);
// found `core::option::Option<_>` (expected f64 but found integral variable)
```

<!-- That doesn’t mean we can’t make `Option<T>`s that hold an `f64`! They just have -->
<!-- That doesn’t mean we can’t make `Option<T>`s that hold an `f64`! They have -->
<!-- to match up: -->
これは `f64` を保持する `Option<T>` が作れないという意味ではありませんからね!
リテラルと宣言の型をぴったり合わせなければなりません
リテラルと宣言の型を合わせなければなりません

```rust
let x: Option<i32> = Some(5);
Expand All @@ -66,7 +66,7 @@ let y: Option<f64> = Some(5.0f64);

<!-- This is just fine. One definition, multiple uses. -->
これだけで結構です。
1つの定義で、多くの用途が得られます
1つの定義で、多くの用途に対応できます

<!-- 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>`: -->
ジェネリクスにおいてジェネリックな型は1つまで、といった制限はありません。
Expand Down Expand Up @@ -157,9 +157,9 @@ let float_origin = Point { x: 0.0, y: 0.0 };
<!-- and we then use `x: T` in the type declaration, too. -->
関数と同様に、 `<T>` がジェネリックパラメータを宣言する場所であり、型宣言において `x: T` を使うのも同じです。

<!-- When you want to add an implementation for the generic `struct`, you just -->
<!-- When you want to add an implementation for the generic `struct`, you -->
<!-- declare the type parameter after the `impl`: -->
ジェネリックな `struct` に実装を追加したい場合、 `impl` の後に型パラメータを宣言するだけです
ジェネリックな `struct` に実装を追加したい場合、 `impl` の後に型パラメータを宣言します

```rust
# struct Point<T> {
Expand Down
21 changes: 0 additions & 21 deletions diff-1.6.0..1.9.0/src/doc/book/generics.md

This file was deleted.