Код: Выделить всё
public class Hashmap where TKey : struct where TValue : struct
{
unsafe public NativeParallelHashMap Load(string folder, string file)
{
// load our nodes from map binary data file and return
Function.HashmapAdapter adapter = new();
BinarySerializationParameters prams = new() { UserDefinedAdapters = new() { adapter } };
byte[] data = File.ReadAllBytes(folder + file);
fixed (void* buffer = data)
{
var reader = new UnsafeAppendBuffer.Reader(buffer, data.Length);
return BinarySerialization.FromBinary(&reader, prams);
}
}
}
Код: Выделить всё
The type 'TValue' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'TValue' in the generic type or method 'HashmapAdapter'
EDIT: я переключил TValue : struct to TValue : unmanaged, и это исправило часть TValue, но TKey по-прежнему выдает ошибку.
Подробнее здесь: https://stackoverflow.com/questions/790 ... ollections