So the field hash for Nat and Int is deprecated but I need a TrieMap with a Nat as its key. Problem is, I really don’t know how to write a hash function or what to consider when hashing a Nat. I thought the following would work, but it’s giving me both the warning about the deprecated hash field and an error:

let myDB = TrieMap.TrieMap<Nat, Text>(Nat.equal, Hash.hash(Nat));

Those hash functions are deprecated because they only look at the lower 32 bits rather than hashing all the bits. That might be fine for your
application if the nats are small anyway.

I think the type error is due to the Hash.hash(Nat). Replace by just Hash.hash.

Hi Aaron! I just went ahead and ignored the warning since I’m only dealing with low values anyway. The reason I decided to stick with Nat instead of changing the type to Nat32 was - if I’m not mistaken - that Nat still has a lower memory footprint than Nat32. At least that’s what I read somewhere.