Skip to content

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

Closed
@JOE1994

Description

@JOE1994

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 🦀

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions