Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deconstruct extension for KeyValuePair<TKey, TValue> #31

Open
Arthri opened this issue Dec 18, 2022 · 1 comment
Open

Deconstruct extension for KeyValuePair<TKey, TValue> #31

Arthri opened this issue Dec 18, 2022 · 1 comment

Comments

@Arthri
Copy link

Arthri commented Dec 18, 2022

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

@maximpashuk
Copy link

I think this is a duplicate with #6 , same things discussed (also support for Deconstruct extensions methods)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants