Book: Reborrows

Created on 10 Nov 2019  路  2Comments  路  Source: rust-lang/book

We need to make sure to talk about reborrows: https://github.com/rust-lang/rust/issues/25899

_Originally posted by @steveklabnik in https://github.com/rust-lang/book/issues/10#issuecomment-169771374_

So that issue was closed but it looks like reborrows are not covered in the book currently.

Specifically, in case with generics they don't work, and need to be written by hand.

Most helpful comment

Hey!

I think reborrows very much fit that book! Knowing that the concept of ownership/borrowing is very important and omnipresent in Rust, I read the chapter extra carefully. After being done with the chapter and playing around with some code there was just one thing that I couldn't explain myself: why is this mut reference still usable after passing it to a function? After a bit of googleing I found that the answer is reborrowing, which happens instead of moving in certain situations. I think that this question comes up naturally when reading the chapter carefully and trying to understand all of the concepts, that's why I think reborrowing should at least be mentioned in the chapter.

[edit] removed second half of my comment as it was unrelated to reborrowing.

All 2 comments

At the time, I thought it was important, but I don't think reborrows fit the book. Thank you for keeping track though!

Hey!

I think reborrows very much fit that book! Knowing that the concept of ownership/borrowing is very important and omnipresent in Rust, I read the chapter extra carefully. After being done with the chapter and playing around with some code there was just one thing that I couldn't explain myself: why is this mut reference still usable after passing it to a function? After a bit of googleing I found that the answer is reborrowing, which happens instead of moving in certain situations. I think that this question comes up naturally when reading the chapter carefully and trying to understand all of the concepts, that's why I think reborrowing should at least be mentioned in the chapter.

[edit] removed second half of my comment as it was unrelated to reborrowing.

Was this page helpful?
0 / 5 - 0 ratings