Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book 4.1 should mention that shadowing does not destroy the original value. #33887

Closed
MichaelNecio opened this issue May 26, 2016 · 2 comments
Closed

Comments

@MichaelNecio
Copy link
Contributor

In reading about shadowing I was curious if shadowing a binding within the same scope would cause a destructor to be called, which I did eventually find is not the case https://www.reddit.com/r/rust/comments/2eelew/unexpected_for_me_behavior/?ref=share&ref_source=link, but perhaps this should be mentioned in the book to prevent incorrect assumptions from being formed (it's happened at least once).

There is currently an example of a binding being shadowed in a new scope and then the old value being used again, but I don't think this is enough for people to make the connection that shadowing never destroys a value ( they could think that the compiler keeps track of whether or not a binding is used again in the same scope ).

@steveklabnik
Copy link
Member

I am not working on the book at the moment, given that I'm working on the second edition. If someone wants to send me a PR for this, I'd take it, though!

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jun 7, 2016
…klabnik

Noted that shadowing never destroys a value

Fixes issue rust-lang#33887

r? @steveklabnik
@steveklabnik
Copy link
Member

this was closed by #34125

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants