Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

birkenfeld
Copy link
Contributor

While it is not useful to list impls here, and there are no inherent methods, references are still a primitive (and very important) type and should get an entry in the overview on http://doc.rust-lang.org/std/#primitives and a place to put general verbiage about references, and probably a reference to the book.

We do not add links to this page from other types, like we do for &[T], because that would likely be more confusing than helpful.

Fixes: #15654

r? @steveklabnik - the documentation I put in primitive_docs.rs is just a placeholder for what you'd like to put there :)

While it is not useful to list impls here, and there are no inherent methods,
references are still a primitive (and very important) type and should get an
entry in the overview on http://doc.rust-lang.org/std/#primitives and a place
to put general verbiage about references, and probably a reference to the book.

We do *not* add links to this page from other types, like we do for `&[T]`,
because that would likely be more confusing than helpful.

Fixes: rust-lang#15654
@steveklabnik
Copy link
Member

Nice, I would like to see this. @alexcrichton is this the right way to do this? It feels right to me, but would like to double check.

/// 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat nuanced where types like &Cell<T> are actually read/write, not just read only. Perhaps this could just indicate "allows aliasing"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the official term is just "reference", not "shared reference"

@alexcrichton
Copy link
Member

Are there any incoming links to this page anywhere as well?

//
/// Borrowed references, `&T`, and `&mut T`.
///
/// References fundamental to Rust's system of ownership and borrowing. They
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

References are fundamental

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to reopen with comments addressed!

@birkenfeld birkenfeld deleted the issue-15654 branch August 7, 2016 08:05
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

Successfully merging this pull request may close these issues.

3 participants