Skip to content

std::rc::try_unwrap() should only consider the strong refcount #24789

Closed
@abonander

Description

@abonander

From this reddit thread.

std::rc::try_unwrap() returns Err if the Rc is not unique, which includes weak references. This fails intuition as the logic is the same as when the last Rc is dropped, which only considers strong references when deciding whether to drop the contained value, except it keeps the contained value from being destroyed. I fail to see how it is unsafe to unwrap when only weak references remain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions