Skip to content

Confusing term ("non-pointer type"s) in docs for 'Deref'/'DerefMut' #72335

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
JOE1994 opened this issue May 18, 2020 · 0 comments · Fixed by #72834
Closed

Confusing term ("non-pointer type"s) in docs for 'Deref'/'DerefMut' #72335

JOE1994 opened this issue May 18, 2020 · 0 comments · Fixed by #72834
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools

Comments

@JOE1994
Copy link
Contributor

JOE1994 commented May 18, 2020

Hi 🦀 ,

I'm a bit confused with the term "non-pointer types" used in the docs for Deref/DerefMut.

  • From docs for Deref
If T implements Deref<Target = U>, and x is a value of type T, then:

    * In immutable contexts, *x on non-pointer types is equivalent to *Deref::deref(&x).
  • From docs for DerefMut
If T implements DerefMut<Target = U>, and x is a value of type T, then:

    * In mutable contexts, *x on non-pointer types is equivalent to *DerefMut::deref_mut(&mut x).

The docs describe behavior of *x on non-pointer types.
If I assume "smart pointer"s are "pointer"s (as the Rust reference does),
it seems quite awkward to discuss behavior of *x on non-pointer types in the docs,
since docs for Deref & DerefMut say that
"Deref/DerefMut should only be implemented for smart pointers".

If the term "non-pointer type" refers to smart pointers in this context,
would it be better to replace the term "non-pointer type" with either
just "smart pointer" or "non-primitive pointer type" ??

Thank you for reading this issue 🦀

@Elinvynia Elinvynia added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label May 20, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jun 1, 2020
…fackler

Rephrase term 'non-pointer type'

Hello 🐈 ,

If the reader assumes that 'pointer type's include 'smart pointer's,
the term 'non-pointer type' could mislead the reader to assume that
x should not be a smart pointer type. I tried to rephrase the term
'non-pointer type' to remove ambiguity in the doc comments.

closes rust-lang#72335

Thank you for reviewing this PR! 🦸‍♀️
@bors bors closed this as completed in 3048a41 Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants