PolySharp
PolySharp copied to clipboard
Deconstruct extension for KeyValuePair<TKey, TValue>
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
I think this is a duplicate with #6 , same things discussed (also support for Deconstruct extensions methods)