Announcing iddqd: maps where keys are borrowed from values

272 points sunshowers6 70 comments

Hi!

Just released a new crate called iddqd, which represents maps where keys are borrowed from values.

For example, consider a User type:

#[derive(Debug)]
struct User {
    name: String,
    age: u8,
}

With iddqd, you can say that the key type is &'a str and then use string lookups to fetch keys.

Four maps are included:

  • IdOrdMap for an ordered map
  • IdHashMap for an unordered map
  • BiHashMap for a 1:1 (bijective) hash map
  • TriHashMap for a 1:1:1 (trijective) hash map

We've found this pattern to be exceedingly useful at Oxide, and we hope you find it useful too. Thanks!