Skip to content

Guard types should implement more traits #24372

Closed
@huonw

Description

@huonw
Member

Types like std::sync::MutexGuard are semantically just a &mut with a destructor, and so it makes sense for them to implement the same sort of traits, e.g. Display and Debug.

Activity

steveklabnik

steveklabnik commented on Jun 27, 2016

@steveklabnik
Member

Triage: MutexGuard does not implement those traits today.

added
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
and removed on Mar 24, 2017
Mark-Simulacrum

Mark-Simulacrum commented on Jun 15, 2017

@Mark-Simulacrum
Member

Debug is implemented today, but not Display.

@rust-lang/libs: This seems relevant to libz blitz, we probably want to work out some guidelines for wrapper types like this (what traits they should "forward"). For example, I can't think of a good Display implementation for MutexGuard, but perhaps there is one.

To an extent, it could be argued that most if not all std traits should be forwarded through types like MutexGuard, but this feels like it gets painful very quickly.

sfackler

sfackler commented on Jun 15, 2017

@sfackler
Member

The Display impl for MutexGuard would just delegate to the inner value's Display.

brson

brson commented on Jun 20, 2017

@brson
Contributor

Smart pointers and guards should eagerly implement common traits. Debug at least should be transparent, custom implemented to defer to the inner type. Not clear whether Eq/Ord should be implemented against the inner type.

Next step here is to identify such types in std and file a PR.

Here's an issue for the guidelines: rust-lang/api-guidelines#94

added
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-help-wantedCall for participation: Help is requested to fix this issue.
and removed on Jun 20, 2017
changed the title [-]Guard types in std::sync should implement more traits[/-] [+]Guard types should implement more traits[/+] on Jun 20, 2017
ChrisMacNaughton

ChrisMacNaughton commented on Jun 22, 2017

@ChrisMacNaughton
Contributor

I'd like to have a go at this one

ChrisMacNaughton

ChrisMacNaughton commented on Jun 22, 2017

@ChrisMacNaughton
Contributor

As a first pass, I'm looking at ensuring that MutexGuard, RwLockReadGuard, and RwLockWriteGuard impl Display and Debug. How does that sound?

23 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.T-libs-apiRelevant to the library API 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

        Participants

        @steveklabnik@alexcrichton@brson@ChrisMacNaughton@huonw

        Issue actions

          Guard types should implement more traits · Issue #24372 · rust-lang/rust