What's the best choice for non-resizable dynamic length arrays in Rust?

Viewed 2000

I'm re-implementing a hashtable in Rust. Eventually I'd like to make this distributed and have quorums, but for now it's a hashtable on a single system.

I want the size of the table to be passed in as an argument so the table should be dynamically sized. I don't want the table to grow because that will mess with my hash function which works off a modulo operation. I see a couple of options:

  1. Arrays - cannot be dynamically sized
  2. Vectors - can grow
  3. Slices - can be dynamically sized & can't grow, but are just views onto Vecs and arrays, so I'll need a Vec/array anyways?

In C++, I could have just used a dynamically sized array. What's the best choice here?

1 Answers
Related