Skip to content

Reintroduce box syntax where needed #22267

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 1 commit into from
Feb 22, 2015
Merged
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
9 changes: 7 additions & 2 deletions src/doc/trpl/pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ than the hundred `int`s that make up the `BigStruct`.

This is an antipattern in Rust. Instead, write this:

```{rust}
```rust
#![feature(box_syntax)]

struct BigStruct {
one: i32,
two: i32,
Expand All @@ -706,10 +708,13 @@ fn main() {
one_hundred: 100,
});

let y = Box::new(foo(x));
let y = box foo(x);
}
```

Note that this uses the `box_syntax` feature gate, so this syntax may change in
the future.

This gives you flexibility without sacrificing performance.

You may think that this gives us terrible performance: return a value and then
Expand Down