diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-01-12 13:57:09 -0500 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-01-12 13:57:09 -0500 |
| commit | db7de969cfb50587475185e25bd09b7e73cafe83 (patch) | |
| tree | a7e87116f627f64a2382c95932e9a1d5fa9bc90c /src/doc/trpl/pointers.md | |
| parent | b21a6da340fd958de370d2b83c0f17fd8fa51f89 (diff) | |
| download | rust-db7de969cfb50587475185e25bd09b7e73cafe83.tar.gz rust-db7de969cfb50587475185e25bd09b7e73cafe83.zip | |
Improve clarity of paragraph in the pointer guide
Fixes #19067
Diffstat (limited to 'src/doc/trpl/pointers.md')
| -rw-r--r-- | src/doc/trpl/pointers.md | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/doc/trpl/pointers.md b/src/doc/trpl/pointers.md index 63c16ef191e..0c72e5c404c 100644 --- a/src/doc/trpl/pointers.md +++ b/src/doc/trpl/pointers.md @@ -721,11 +721,10 @@ fn main() { This gives you flexibility without sacrificing performance. You may think that this gives us terrible performance: return a value and then -immediately box it up ?! Isn't that the worst of both worlds? Rust is smarter -than that. There is no copy in this code. `main` allocates enough room for the -`box`, passes a pointer to that memory into `foo` as `x`, and then `foo` writes -the value straight into that pointer. This writes the return value directly into -the allocated box. +immediately box it up ?! Isn't this pattern the worst of both worlds? Rust is +smarter than that. There is no copy in this code. `main` allocates enough room +for the `box`, passes a pointer to that memory into `foo` as `x`, and then +`foo` writes the value straight into the `Box<T>`. This is important enough that it bears repeating: pointers are not for optimizing returning values from your code. Allow the caller to choose how they |
