-
Notifications
You must be signed in to change notification settings - Fork 13.4k
doc: add a "primitive type reference" page #33516
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,27 @@ mod prim_char { } | |
/// | ||
mod prim_unit { } | ||
|
||
#[doc(primitive = "ref")] | ||
// | ||
/// Borrowed references, `&T`, and `&mut T`. | ||
/// | ||
/// References fundamental to Rust's system of ownership and borrowing. They | ||
/// are represented as pointers, but the compiler can statically ensure that no | ||
/// unsafety results from passing and dereferencing them. | ||
/// | ||
/// Shared references (`&T`) allow read-only access to the pointee, while | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is somewhat nuanced where types like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the official term is just "reference", not "shared reference" |
||
/// mutable references (`&mut T`) allow full access, which is why mutable | ||
/// references are enforced to be exclusive. | ||
/// | ||
/// (Point to the section in the book?) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This'll probably wanna be changed before landing |
||
/// | ||
/// Reference types have no inherent methods. Any methods called on a reference | ||
/// will be resolved to methods on the pointee. However, traits can be | ||
/// implemented for reference types. These implementations will show up in the | ||
/// documentation for the pointee type. | ||
/// | ||
mod prim_ref { } | ||
|
||
#[doc(primitive = "pointer")] | ||
// | ||
/// Raw, unsafe pointers, `*const T`, and `*mut T`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
References are fundamental