1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-27 20:58:41 +02:00

Refer to Godbolt (#1011)

* Refer to Godbolt

* Apply suggestions from code review

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
This commit is contained in:
Dominik Maier 2023-07-20 17:46:50 +02:00 committed by GitHub
parent 7bd1bcc99f
commit bd4839e394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ fn main() {
<details>
Notes on stack returns:
* Demonstrate that the return from `add` is cheap because the compiler can eliminate the copy operation. Change the above code to print stack addresses and run it on the [Playground]. In the "DEBUG" optimization level, the addresses should change, while they stay the same when changing to the "RELEASE" setting:
* Demonstrate that the return from `add` is cheap because the compiler can eliminate the copy operation. Change the above code to print stack addresses and run it on the [Playground] or look at the assembly in [Godbold](https://rust.godbolt.org/). In the "DEBUG" optimization level, the addresses should change, while they stay the same when changing to the "RELEASE" setting:
```rust,editable
#[derive(Debug)]
@ -37,7 +37,7 @@ Notes on stack returns:
p
}
fn main() {
pub fn main() {
let p1 = Point(3, 4);
let p2 = Point(10, 20);
let p3 = add(&p1, &p2);
@ -50,4 +50,4 @@ Notes on stack returns:
</details>
[Playground]: https://play.rust-lang.org/
[Playground]: https://play.rust-lang.org/