I am currently reading the source code of rust and am interested in the underlying details of the Raw pointer, but when I googled the information I found a problem, most of the information is only general and does not cover the essence of the Raw pointer, how can I understand the Raw pointer and the underlying details of the encapsulation of rust from the ground up?
(member of the new T-opsem, speaking on my own)
Rust raw pointers behave like pointers in C do; they point to some place in memory, and you can read or write the memory at that location. You can't use a pointer to access memory from a separate allocated object than the one it was originally created for (and this is a rule in C as well, though there it's a bit circuitous why). Strictly speaking, that's the end of it; any further restrictions come from interactions with other parts of the language which are stricter than C.
The exact specifics beyond that aren't very specific yet. If you'd like to know more about the current understanding, recommended reading includes (but is not limited to)
- RalfJ on provenance:
- Gankra on provenance:
- RalfJ on Stacked Borrows:
- unsafe-code-guidelines/stacked-borrows.md at master · rust-lang/unsafe-code-guidelines · GitHub
- (links out to a bunch more as well)
Please don't cross-post the same topic here and on users.rust-lang.org. (URLO is more appropriate for this particular question.)
I am closing this thread, further discussion can happen in the URLO thread, as it's already more active and seems the more fitting place.