Email or username:

Password:

Forgot your password?
Top-level
Mara

@swiftcoder Huh? The let binding is for the value that will be lifetime-extended. (It's no longer a "temporary" because it now has a name.)

2 comments
Tristam

@Mara in that case seems I misunderstood. Super let only extends its own lifetime, not the lifetime of any temporaries nested within expressions?

Mara

@swiftcoder Ah. Well, both?

`super let a = Thing;` makes `a` live as long as the surrounding block. The lifetime that allows the block's final expression to be `&a`, basically.

On top of that, we still have temporary lifetime extension, just like we have in a regular `let`:

`let a = &temp();` makes the temporary life as long as `a`.

Same for `super let a = &temp();`: the temporary will live as long as `a` (which might live longer than it would have in a regular `let`).

Go Up