summary refs log tree commit diff
path: root/LibGit/Extensions/DictionaryExtensions.cs
blob: 0e6df064b4c2d9d5f72aa4a36997c421c290fce7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
namespace LibGit.Extensions;

public static class DictionaryExtensions
{
    public static bool ChangeKey<TKey, TValue>(this IDictionary<TKey, TValue> dict, 
        TKey oldKey, TKey newKey)
    {
        TValue value;
        if (!dict.Remove(oldKey, out value))
            return false;

        dict[newKey] = value;  // or dict.Add(newKey, value) depending on ur comfort
        return true;
    }
}