Skip to content
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
19 changes: 9 additions & 10 deletions 1.9/ja/book/closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ assert_eq!(5, num);

<!-- Rust’s implementation of closures is a bit different than other languages. They -->
<!-- are effectively syntax sugar for traits. You’ll want to make sure to have read -->
<!-- the [traits chapter][traits] before this one, as well as the chapter on [trait -->
<!-- the [traits][traits] section before this one, as well as the section on [trait -->
<!-- objects][trait-objects]. -->
Rustにおけるクロージャの実装は他の言語とは少し異なります。
Rustにおけるクロージャは実質的にトレイトへの糖衣構文です。
続きの説明を読む前に [トレイト][traits] や [トレイトオブジェクト][trait-objects] についてのチャプターを学ぶ前に読みたくなるでしょう
続きの説明を読む前に [トレイト][traits] や [トレイトオブジェクト][trait-objects] についてのセクションを学ぶ前に読みたくなるでしょう

[traits]: traits.html
[trait-objects]: trait-objects.html
Expand Down Expand Up @@ -330,9 +330,9 @@ Rustは環境用の構造体を作成し、 適切なトレイトを `impl` し
# クロージャを引数に取る

<!-- Now that we know that closures are traits, we already know how to accept and -->
<!-- return closures: just like any other trait! -->
<!-- return closures: the same as any other trait! -->
クロージャが実際にはトレイトであることを学んだので、
クロージャを引数としたり返り値としたりする方法を既に知っていることになります: 通常のトレイトと同様に行うのです!
クロージャを引数としたり返り値としたりする方法を既に知っていることになります: 通常のトレイトと全く同様に行うのです!

<!-- This also means that we can choose static vs dynamic dispatch as well. First, -->
<!-- let’s write a function which takes something callable, calls it, and returns -->
Expand All @@ -352,7 +352,7 @@ let answer = call_with_one(|x| x + 2);
assert_eq!(3, answer);
```

<!-- We pass our closure, `|x| x + 2`, to `call_with_one`. It just does what it -->
<!-- We pass our closure, `|x| x + 2`, to `call_with_one`. It does what it -->
<!-- suggests: it calls the closure, giving it `1` as an argument. -->
クロージャ `|x| x + 2` を `call_with_one` に渡しました。
`call_with_one` はその関数名から推測される処理を行います: クロージャに `1` を与えて呼び出します。
Expand Down Expand Up @@ -479,14 +479,13 @@ assert_eq!(6, answer);
このコードは以下の長いエラーを発生させます:

```text
error: the trait `core::marker::Sized` is not implemented for the type
`core::ops::Fn(i32) -> i32` [E0277]
error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
fn factory() -> (Fn(i32) -> i32) {
^~~~~~~~~~~~~~~~
note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time
fn factory() -> (Fn(i32) -> i32) {
^~~~~~~~~~~~~~~~
error: the trait `core::marker::Sized` is not implemented for the type `core::ops::Fn(i32) -> i32` [E0277]
error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
let f = factory();
^
note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time
Expand Down Expand Up @@ -570,7 +569,7 @@ error: mismatched types:


<!-- Because each closure generates its own environment `struct` and implementation -->
<!-- of `Fn` and friends, these types are anonymous. They exist just solely for -->
<!-- of `Fn` and friends, these types are anonymous. They exist solely for -->
<!-- this closure. So Rust shows them as `closure@<anon>`, rather than some -->
<!-- autogenerated name. -->
それぞれのクロージャはそれぞれの環境用の `struct` を生成し、
Expand Down Expand Up @@ -642,7 +641,7 @@ assert_eq!(6, answer);
```

<!-- By making the inner closure a `move Fn`, we create a new stack frame for our -->
<!-- closure. By `Box`ing it up, we’ve given it a known size, and allowing it to -->
<!-- closure. By `Box`ing it up, we’ve given it a known size, allowing it to -->
<!-- escape our stack frame. -->
`factory()` 内のクロージャを `move Fn` にすることで、新しいスタックフレームをクロージャのために生成します。
そしてボックス化することによって、既知のサイズとなり、現在のスタックフレームから抜けることが可能になります。
63 changes: 0 additions & 63 deletions diff-1.6.0..1.9.0/src/doc/book/closures.md

This file was deleted.