Skip to content

Tracking issue for downgraded_weak (No way to construct std::rc::Weak without a strong reference) #30425

Closed
@shahn

Description

@shahn

When deserializing Weak, there's currently no clean way to handle the case that there's no strong reference anymore. Serializing doesn't have the same issue. There seem to be two solutions to this, either provide an explicit constructor that returns a Weak without using a strong reference to create it, or implementing Default for it that does the same. I prefer the former, as Default might be a bit surprising.

This would be a simple, non-backwards-incompatible change. Possible constructor name bikeshedding: Weak::new_downgraded()

Unstable APIs

  • Weak::new

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions