File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change 5
5
<!-- Also it is not possible in stable Rust to destructure a `Box` in a match -->
6
6
<!-- pattern. The unstable `box` keyword can be used to both create and destructure -->
7
7
<!-- a `Box`. An example usage would be: -->
8
- 今のところ、stableにおいて ` Box ` を作成する唯一の方法は ` Box::new ` メソッドです。stableなRustではパターンマッチで ` Box ` を分解することもできません。unstableな ` box ` キーワードは ` Box ` の作成と分解の両方に使えます。使い方は以下の通りです。
8
+ 今のところ、安定版において ` Box ` を作成する唯一の方法は ` Box::new ` メソッドです。安定版のRustではパターンマッチで ` Box ` を分解することもできません。不安定版の ` box ` キーワードは ` Box ` の作成と分解の両方に使えます。使い方は以下の通りです。
9
9
10
10
``` rust
11
11
#![feature(box_syntax, box_patterns)]
@@ -102,7 +102,7 @@ fn main() {
102
102
<!-- smarter than that. There is no copy in this code. `main` allocates enough room -->
103
103
<!-- for the `box`, passes a pointer to that memory into `foo` as `x`, and then -->
104
104
<!-- `foo` writes the value straight into the `Box<T>`. -->
105
- このコードはひどいパフォーマンス低下をもたらすと感じるかもしれません。値を返して即座にboxに入れるなんて?! このパターンは悪いところどりになっているのでは? Rustはもう少し賢いため、このコードでコピーは発生しません。 ` main ` では ` box ` のために十分な領域を確保し 、そのメモリへのポインタを ` foo ` へ ` x ` として渡します。 ` foo ` はその値を直接 ` Box<T> ` (訳注: すなわち ` y ` )の中に書き込みます。
105
+ このコードはひどいパフォーマンス低下をもたらすと感じるかもしれません。値を返して即座にboxに入れるなんて?! このパターンは悪いところどりになっているのでは? Rustはもう少し賢いため、このコードでコピーは発生しません。 ` main ` 内では ` box ` のために十分なメモリ領域を確保し 、そのメモリへのポインタを ` foo ` へ ` x ` として渡します。 ` foo ` はその値を直接 ` Box<T> ` (訳注: すなわち ` y ` )の中に書き込みます。
106
106
107
107
<!-- This is important enough that it bears repeating: pointers are not for -->
108
108
<!-- optimizing returning values from your code. Allow the caller to choose how they -->
You can’t perform that action at this time.
0 commit comments