Memory Management
Modern programming languages that we work with these days have made memory management simpler that ever, they manage it on their own using things like garbage collectors, smart pointers, ownership, etc. Creating an empty vector is as simple as let empty_vec: Vec<i32> = Vec::new(); But some questions remain unanswered if you haven’t tried manually doing memory operations like: how is a sized vector created using Vec::with_capacity? how is a vector resized on calling pop_back or push_back? and finally how is the memory freed when vector goes out of scope? Let’s engage in old god C as its closest we get to actual system calls and try to figure out these question inside out. ...