Lantua
1
So, does
_ = c
count as a usage of c? Would the compiler deinit c before this line if there's no access to c afterward?
Without wanting to fall in the XY trap, isn't withExtendedLifetime the "official" way to prevent any unwanted deinitialization?
Lantua
3
That would be, and that's also why I'm reluctant to also suggest _ = c when answering this question–Avoid a "variable was written to, but never read" without unnecessary read statements - #2 by Lantua.
This warning is painful indeed. Dummy assignment is also my workaround. But I avoid mixing this with lifetime management.
1 Like
Joe_Groff
(Joe Groff)
5
_ = c does not count as a use of the loaded value from c, so if your goal is to delay its potential destruction, you'll still need to use withExtendedLifetime.
4 Likes