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
6 changes: 6 additions & 0 deletions text/3606-temporary-lifetimes-in-tail-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

In the next edition, drop temporaries in tail expressions *before* dropping locals, rather than after.

![A diagram showing a function with one let statement "let x = g();" and a tail expression "temp().h()"
and a visualisation of how long x and temp live before and after this change.
Before: x is created first, then temp is created, then x is dropped, then temp is dropped.
After: x is created first, then temp is created, then temp is dropped, then x is dropped.
](3606-temporary-lifetimes-in-tail-expressions/diagram.svg)

# Motivation

Temporaries in the tail expression in a block live longer than the block itself,
Expand Down
4 changes: 4 additions & 0 deletions text/3606-temporary-lifetimes-in-tail-expressions/diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.