Shadowed variable former value lifetime

Hi everyone,

When the former value of a shadowed variable is removed from the memory?

Thanks and have a nice weekend!

A variable's drop scope doesn't change when it gets shadowed, so, where ever it would have been removed without the shadowing (most frequently the end of the containing block).


If you wanted something else to happen, you could explicitly drop(the_variable) before shadowing.


1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.