Skip to content

Deconstruct extension for KeyValuePair<TKey, TValue> #31

@Arthri

Description

@Arthri

Description (optional)

Add an extension to KeyValuePair<TKey, TValue> that mirrors https://learn.microsoft.com/en-US/dotnet/api/system.collections.generic.keyvaluepair-2.deconstruct?view=net-7.0

Rationale

The extension allows for KeyValuePairs to be deconstructed in scenarios such as

foreach ((var k, var v) in dict)
{
    // ...
}

Proposed API

https://learn.microsoft.com/en-US/dotnet/api/system.collections.generic.keyvaluepair-2.deconstruct?view=net-7.0 Allows the compiler to deconstruct KeyValuePairs in tuple patterns or other tuple-like scenarios

Drawbacks

Not known

Alternatives

Not known

Other thoughts

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions