Skip to content

RwLock::try_write should say that it fails with WouldBlock if there's a shared lock #142852

@MetaflameDragon

Description

@MetaflameDragon

Location

https://doc.rust-lang.org/std/sync/struct.RwLock.html#method.try_write

Summary

The docs for RwLock::try_write say:

This function will return the WouldBlock error if the RwLock could not be acquired because it was already locked exclusively.

I believe it should say "because it already has a shared or exclusive lock", based on how RwLock works (and based on my reading of the code). The sibling methods (read, write) clarify this detail correctly, and try_write's docs appear to be copied from try_read (where this description is correct), so I think this is just a small oversight from copying the description.

(For context, I was initially checking whether RwLock had some way to indicate that the lock was writer-locked, and this description confused me at first.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions