@@ -267,11 +267,11 @@ assert_eq!(5, num);
267267
268268<!-- Rust’s implementation of closures is a bit different than other languages. They -->
269269<!-- are effectively syntax sugar for traits. You’ll want to make sure to have read -->
270- <!-- the [traits chapter ][traits] before this one, as well as the chapter on [trait -->
270+ <!-- the [traits][traits] section before this one, as well as the section on [trait -->
271271<!-- objects][trait-objects]. -->
272272Rustにおけるクロージャの実装は他の言語とは少し異なります。
273273Rustにおけるクロージャは実質的にトレイトへの糖衣構文です。
274- 続きの説明を読む前に [ トレイト] [ traits ] や [ トレイトオブジェクト] [ trait-objects ] についてのチャプターを学ぶ前に読みたくなるでしょう 。
274+ 続きの説明を読む前に [ トレイト] [ traits ] や [ トレイトオブジェクト] [ trait-objects ] についてのセクションを学ぶ前に読みたくなるでしょう 。
275275
276276[ traits ] : traits.html
277277[ trait-objects ] : trait-objects.html
@@ -330,9 +330,9 @@ Rustは環境用の構造体を作成し、 適切なトレイトを `impl` し
330330# クロージャを引数に取る
331331
332332<!-- Now that we know that closures are traits, we already know how to accept and -->
333- <!-- return closures: just like any other trait! -->
333+ <!-- return closures: the same as any other trait! -->
334334クロージャが実際にはトレイトであることを学んだので、
335- クロージャを引数としたり返り値としたりする方法を既に知っていることになります: 通常のトレイトと同様に行うのです !
335+ クロージャを引数としたり返り値としたりする方法を既に知っていることになります: 通常のトレイトと全く同様に行うのです !
336336
337337<!-- This also means that we can choose static vs dynamic dispatch as well. First, -->
338338<!-- let’s write a function which takes something callable, calls it, and returns -->
@@ -352,7 +352,7 @@ let answer = call_with_one(|x| x + 2);
352352assert_eq! (3 , answer );
353353```
354354
355- <!-- We pass our closure, `|x| x + 2`, to `call_with_one`. It just does what it -->
355+ <!-- We pass our closure, `|x| x + 2`, to `call_with_one`. It does what it -->
356356<!-- suggests: it calls the closure, giving it `1` as an argument. -->
357357クロージャ ` |x| x + 2 ` を ` call_with_one ` に渡しました。
358358` call_with_one ` はその関数名から推測される処理を行います: クロージャに ` 1 ` を与えて呼び出します。
@@ -479,14 +479,13 @@ assert_eq!(6, answer);
479479このコードは以下の長いエラーを発生させます:
480480
481481``` text
482- error: the trait `core::marker::Sized` is not implemented for the type
483- `core::ops::Fn(i32) -> i32` [E0277]
482+ error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
484483fn factory() -> (Fn(i32) -> i32) {
485484 ^~~~~~~~~~~~~~~~
486485note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time
487486fn factory() -> (Fn(i32) -> i32) {
488487 ^~~~~~~~~~~~~~~~
489- error: the trait `core::marker::Sized` is not implemented for the type `core::ops::Fn(i32) -> i32` [E0277]
488+ error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
490489let f = factory();
491490 ^
492491note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time
@@ -570,7 +569,7 @@ error: mismatched types:
570569
571570
572571<!-- Because each closure generates its own environment `struct` and implementation -->
573- <!-- of `Fn` and friends, these types are anonymous. They exist just solely for -->
572+ <!-- of `Fn` and friends, these types are anonymous. They exist solely for -->
574573<!-- this closure. So Rust shows them as `closure@<anon>`, rather than some -->
575574<!-- autogenerated name. -->
576575それぞれのクロージャはそれぞれの環境用の ` struct ` を生成し、
@@ -642,7 +641,7 @@ assert_eq!(6, answer);
642641```
643642
644643<!-- By making the inner closure a `move Fn`, we create a new stack frame for our -->
645- <!-- closure. By `Box`ing it up, we’ve given it a known size, and allowing it to -->
644+ <!-- closure. By `Box`ing it up, we’ve given it a known size, allowing it to -->
646645<!-- escape our stack frame. -->
647646` factory() ` 内のクロージャを ` move Fn ` にすることで、新しいスタックフレームをクロージャのために生成します。
648647そしてボックス化することによって、既知のサイズとなり、現在のスタックフレームから抜けることが可能になります。
0 commit comments