Weak::as_ptr claims it can return null, which is impossible
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Current documentation as of 1.96.1:
Returns a raw pointer to the object T pointed to by this Weak.
The pointer is valid only if there are some strong references. The pointer may be dangling, unaligned or even null otherwise.
Weak is internally represented by NonNull (and therefore is subject to niche optimization), so a null pointer cannot be returned. Flipping this to guarantee the returned pointer is non null would be useful as there are no NonNull variants of as_ptr and into_ptr yet.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Weak::as_ptr documentation quoted in the issue and inspect how Weak's NonNull representation affects its pointer guarantees. Determine whether the documentation should guarantee a non-null result or whether the API design needs further discussion; done means the documented contract accurately matches the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100