1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2026-02-25 11:08:17 +01:00
Files
Minecraft-Phantom-Panel/Utils/Phantom.Utils/Collections/ImmutableCollectionExtensions.cs

18 lines
493 B
C#

using System.Collections.Immutable;
namespace Phantom.Utils.Collections;
public static class ImmutableCollectionExtensions {
extension(ImmutableDictionary) {
public static ImmutableDictionary<TKey, TValue> From<TKey, TValue>(ReadOnlySpan<(TKey, TValue)> pairs) where TKey : notnull {
var builder = ImmutableDictionary.CreateBuilder<TKey, TValue>();
foreach ((TKey key, TValue value) in pairs) {
builder.Add(key, value);
}
return builder.ToImmutable();
}
}
}