- Add links to the GNU libc docs for `memmove`, `memcpy`, and `memset`, as well as internally linking to other functions in `std::ptr` - List invariants which, when violated, cause UB for all functions - Add example to `ptr::drop_in_place` and compares it to `ptr::read`. - Add examples which more closely mirror real world uses for the functions in `std::ptr`. Also, move the reimplementation of `mem::swap` to the examples of `ptr::read` and use a more interesting example for `copy_nonoverlapping`. - Change module level description - Define what constitutes a "valid" pointer. - Centralize discussion of ownership of bitwise copies in `ptr::read` and provide an example.
Mention alignment in top-level docs
This also removes the overlong link that failed tidy xD.
Update docs for swap_nonoverlapping
They closely mirror the docs for `copy_nonoverlapping`
Remove definiton of valid pointer
The enumerated list of conditions is replaced by an explanation that rust doesn't have a formal memory model. It does say that pointers created directly from references are guaranteed to be valid, and links to both the "Unsafe Code" section of the book and the "Undefined Behavior" section of the reference.
Uses `x.offset(i)` must be valid for all `i` in `0..count`.
Incorporate RalfJung's suggestions
This splits "valid" into "valid for reads" and "valid for writes", and also adds the concept of operation size to validity. Now functions which operate on sequences state that e.g. pointer args must be "valid for reads of size x".
Add a list of known facts re: validity
Also rewrites the reads/writes section to be less reliant on `*const`, `*mut`
turn ptr type method docs into links to docs of free functions, to av…
…oid duplication and inconsistency
The whole keyword docs thing is pretty new in Rust's history and needs some work before it's a shining gem. Here's hoping I can provide that. I basically shoved in a bunch of the most important information from the reference and the book, along with leaving links to both at the end. I don't think keyword docs need to have complete detail, just all the broad strokes, so if someone's confused about a usage of a keyword they can look at the std documentation for that keyword.
It's pretty basic and could do with more details, but it's a good starter until someone else improves it.
Turns out writing docs on keywords that are used in multiple different places in entirely different contexts gets a little harder. I put a footnote on `*const` syntax just to make sure you can find it if need be, but it might need more detail.
Fix a few small things, re-word others
Mostly addressing notes on ambiguous syntax and spurious newlines.
Add debug_assert!s to slice::from_raw_parts
Copy the documentation over to `slice::from_raw_parts_mut`.
I think it might be used in some other things, but I'm not fluent enough at sifting through the rust compiler's source code to find every use of a specific keyword. This leaves the question of how to document the `extern` keyword, what with how much overlap it has with `crate`, but that's used with ABI stuff so that should be fine.