@@ -28,7 +28,7 @@ impl Circle {
28
28
<!-- Traits are similar, except that we first define a trait with a method
29
29
signature, then implement the trait for a type. In this example, we implement the trait `HasArea` for `Circle`: -->
30
30
始めにトレイトをメソッドのシグネチャと共に定義し、続いてある型のためにトレイトを実装するという流れを除けばトレイトはメソッド構文に似ています。
31
- この例では、 ` Circle ` のために ` HasArea ` トレイトを実装しています。
31
+ この例では、 ` Circle ` に ` HasArea ` トレイトを実装しています。
32
32
33
33
``` rust
34
34
struct Circle {
@@ -178,7 +178,7 @@ error: the trait `HasArea` is not implemented for the type `_` [E0277]
178
178
<!-- Your generic structs can also benefit from trait bounds. All you need to
179
179
do is append the bound when you declare type parameters. Here is a new
180
180
type `Rectangle<T>` and its operation `is_square()`: -->
181
- ジェネリック構造体もトレイト境界による恩恵を受けることができます。あなたがしなければならないのは型パラメータを宣言する際に境界を追加することだけです 。以下が新しい型 ` Rectangle<T> ` とそのメソッド ` is_square() ` です。
181
+ ジェネリック構造体もトレイト境界による恩恵を受けることができます。型パラメータを宣言する際に境界を追加するだけで良いのです 。以下が新しい型 ` Rectangle<T> ` とそのメソッド ` is_square() ` です。
182
182
183
183
``` rust
184
184
struct Rectangle <T > {
@@ -219,7 +219,7 @@ impl<T: PartialEq> Rectangle<T> { ... }
219
219
220
220
<!-- Now, a rectangle can be defined in terms of any type that can be compared for
221
221
equality. -->
222
- 今、比較して等しさを確かめることのできる型について長方形を定義できました 。
222
+ これで、長方形を等値性の比較できる任意の型として定義できました 。
223
223
224
224
[ PartialEq ] : ../core/cmp/trait.PartialEq.html
225
225
@@ -228,7 +228,7 @@ precision—really, objects of pretty much any type—as long as they can be
228
228
compared for equality. Could we do the same for our `HasArea` structs, `Square`
229
229
and `Circle`? Yes, but they need multiplication, and to work with that we need
230
230
to know more about [operator traits][operators-and-overloading]. -->
231
- 上記の例では任意の精度を許容する ` Rectangle ` 構造体を新たに定義しました-実のところ、比較して等しさを確かめることのできるほぼ全ての型に対して利用可能なオブジェクトです 。同じことを ` Square ` や ` Circle ` のような ` HasArea ` を実装する構造体に対してできるでしょうか?可能では有りますが乗算が必要になるため、それをするには [ オペレータトレイト] [ operators-and-overloading ] についてより詳しく知らなければなりません。
231
+ 上記の例では任意の精度の数値を受け入れる ` Rectangle ` 構造体を新たに定義しました-実は、等値性を比較できるほぼ全ての型に対して利用可能なオブジェクトです 。同じことを ` Square ` や ` Circle ` のような ` HasArea ` を実装する構造体に対してできるでしょうか?可能では有りますが乗算が必要になるため、それをするには [ オペレータトレイト] [ operators-and-overloading ] についてより詳しく知らなければなりません。
232
232
233
233
[ operators-and-overloading ] : operators-and-overloading.html
234
234
@@ -238,7 +238,7 @@ to know more about [operator traits][operators-and-overloading]. -->
238
238
<!-- So far, we’ve only added trait implementations to structs, but you can
239
239
implement a trait for any type. So technically, we _could_ implement `HasArea`
240
240
for `i32`: -->
241
- ここまでで、構造体へトレイトの実装を追加することだけを説明してきましたが、あらゆる型についてトレイトを実装することもできます。技術的には、 ` i32 ` のための ` HasArea ` を実装することも _ できなくはない_ です。
241
+ ここまでで、構造体へトレイトの実装を追加することだけを説明してきましたが、あらゆる型についてトレイトを実装することもできます。技術的には、 ` i32 ` に ` HasArea ` を実装することも _ できなくはない_ です。
242
242
243
243
``` rust
244
244
trait HasArea {
@@ -266,13 +266,13 @@ that if the trait isn’t defined in your scope, it doesn’t apply. Here’s an
266
266
example: the standard library provides a [`Write`][write] trait which adds
267
267
extra functionality to `File`s, for doing file I/O. By default, a `File`
268
268
won’t have its methods: -->
269
- ここまでくると何でもありなように思えますが 、手が負えなくなることを防ぐためにトレイトの実装周りには2つの制限が設けられています。第1に、あなたのスコープ内で定義されていないトレイトは適用されません。例えば、標準ライブラリは ` File ` にI/O機能を追加するための ` Write ` トレイトを提供しています。デフォルトでは、 ` File ` はそのメソッドを持っていません 。
269
+ ここまでくると世紀末感漂いますが 、手が負えなくなることを防ぐためにトレイトの実装周りには2つの制限が設けられています。第1に、あなたのスコープ内で定義されていないトレイトは適用されません。例えば、標準ライブラリは ` File ` にI/O機能を追加するための ` Write ` トレイトを提供しています。デフォルトでは、 ` File ` は ` Writes ` で定義されるメソッド群を持っていません 。
270
270
271
271
[ write ] : ../std/io/trait.Write.html
272
272
273
273
``` rust,ignore
274
274
let mut f = std::fs::File::open("foo.txt").expect("Couldn’t open foo.txt");
275
- # let buf = b"whatever"; // byte string literal. buf: &[u8; 8]
275
+ # // let buf = b"whatever"; // byte string literal. buf: &[u8; 8]
276
276
let buf = b"whatever"; // buf: &[u8; 8] はバイト文字列リテラルです。
277
277
let result = f.write(buf);
278
278
# // result.unwrap(); // ignore the error
@@ -400,7 +400,7 @@ fn main() {
400
400
All you need to do is leave off the bounds when defining your type parameters,
401
401
and then add `where` after the parameter list. For longer lists, whitespace can
402
402
be added: -->
403
- ` foo() ` は先程見せたままの構文で、 ` bar() ` は ` where ` 節を用いています。あなたに必要なのは型パラメータを定義する際に境界の設定をせず 、引数リストの後ろに ` where ` を追加することだけです 。長いリストであれば、空白を加えることもできます。
403
+ ` foo() ` は先程見せたままの構文で、 ` bar() ` は ` where ` 節を用いています。型パラメータを定義する際に境界の設定をせず 、引数リストの後ろに ` where ` を追加するだけで良いのです 。長いリストであれば、空白を加えることもできます。
404
404
405
405
``` rust
406
406
use std :: fmt :: Debug ;
@@ -416,7 +416,7 @@ fn bar<T, K>(x: T, y: K)
416
416
```
417
417
418
418
<!-- This flexibility can add clarity in complex situations. -->
419
- この柔軟性により複雑な状況であっても明瞭さを付加することができます 。
419
+ この柔軟性により複雑な状況であっても可読性を改善できます 。
420
420
421
421
<!-- `where` is also more powerful than the simpler syntax. For example: -->
422
422
また、` where ` は基本の構文よりも強力です。例えば、
0 commit comments