0

I have an enum that looks a bit like this:

pub enum VmObj {
  ...
  vm_arr_int {
    mark: u64,
    length: i32,
    elements: Vec<i32>,
  },
  ...
}

It's being used to implement mutable storage of integers (in the Vec) for a simple interpreter I'm writing to teach myself Rust but I'm having problems reasoning about what needs to be a reference.

What does the actual layout of a Vec look like in memory?

kittylyst
  • 5,640
  • 2
  • 23
  • 36
  • [Vec](https://github.com/rust-lang/rust/blob/827a141466e7bb85eb3c030600878a2c606019e9/src/liballoc/vec.rs#L293-L296), [RawVec](https://github.com/rust-lang/rust/blob/827a141466e7bb85eb3c030600878a2c606019e9/src/liballoc/raw_vec.rs#L42-L46) – hellow Feb 13 '19 at 09:49
  • FYI storing the length as a separate entity isn't necessary, and is in fact bad practice. Vec stores its own length. – Alexander Feb 13 '19 at 23:54

0 Answers0