For this extension, I implemented a Stack using vectors(from the rust standard library), and then showcased the unqiue referencing and borrowing rules in rust through the pop and bad_pop methods.
The bad_pop method showcases the unique referencing and borrowing rules. The method takes a mutable reference to itself, and then returns a reference to the object being popped off the stack(the stack itself contains references to generics, not the generic itself)
The problem is that the peek method takes in a immutable reference to the object, remove method takes in a mutable reference. Because of the strict referencing rules in rust, this is not allowed. To my understanding, Rust wants to limit the possibilities of data races(the idea that you remove the element before you return its value), so it does not allow code like this to exist.
The solution to this method is to return the object itself from the stack, rather than a reference to the method. This is showcased to the left, where we simply call the remove function on the element at the top of the stack.