mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2026-02-25 11:08:17 +01:00
18 lines
493 B
C#
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();
|
|
}
|
|
}
|
|
}
|