File tree 1 file changed +11
-5
lines changed 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -89,15 +89,21 @@ innermost enclosing statement; the tail expression of a block is considered
89
89
part of the statement that encloses the block.
90
90
91
91
A first exception is when a temporary value is created in the
92
- condition expression of an ` if ` or an ` if ` /` else ` expression.
93
- In this case, the lifetime ends right after the condition expression.
92
+ condition expression of an ` if ` or an ` if ` /` else ` expression or in the
93
+ loop conditional expression of a ` while ` expression.
94
+ In this case, the lifetime ends right after the condition expression or the
95
+ loop conditional expression.
94
96
95
- Here is an example :
97
+ Here are some examples :
96
98
97
- - ` let x = if foo(&temp()) {bar()} else {bas ()}; ` . The expression ` temp() ` is
99
+ - ` let x = if foo(&temp()) {bar()} else {baz ()} ` . The expression ` temp() ` is
98
100
an rvalue. As the temporary is created in the condition expression
99
101
of an ` if ` /` else ` , it will be freed at the end of the condition expression
100
- (in this example before the call to ` bar ` or ` bas ` is made).
102
+ (in this example before the call to ` bar ` or ` baz ` is made).
103
+ - ` while foo(&temp()) {bar();} ` . The temporary containing the return value from
104
+ the call to ` temp() ` is created in the loop conditional expression. Hence it
105
+ will be freed at the end of the loop conditional expression (in this example
106
+ before the call to ` bar ` if the loop body is executed).
101
107
102
108
Another exception is when a temporary rvalue is being created that is assigned
103
109
into a ` let ` declaration. In this case the temporary is created with the
You can’t perform that action at this time.
0 commit comments