rust-lang / rust-lang/rust

Add cross link from Any to Arc/Rc to document downcasting works differently than for Box

Open
#147,651 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-docs T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Location (URL)

https://doc.rust-lang.org/stable/std/any/trait.Any.html

Summary

Any downcasting is implemented for dyn Any as well as Box<Any> (and Send/Sync versions of those). For Arc there is an inherent method instead. Same for Rc.

I did not find these inherent methods, leading to me to open a question on URLO. It would be good to have some cross links from Any to indicate this.

There is even a section in the module level docs on smart pointers but no mention of this downcasting.

There is a mention of Box<dyn Any> in the first section, but I did not spot that, as Box is also listed as an impl of Any, while Arc is not.

This is all really strange and confusing, and not very discoverable. I don't know what the proper fix is or where it should be documented. But some cross-links are very much needed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Any trait documentation and the module's “Smart pointers and dyn Any” section linked in the issue. Compare the existing Box downcasting explanation with Arc::downcast and Rc::downcast, then add cross-links that make those inherent methods discoverable; the documentation should clearly explain that their downcasting differs from Box.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.