▲ | tsimionescu 7 months ago | |||||||
How about going off the end of the vector with an iterator, or modifying the vector while iterating it, or adding to the vector from two different threads or reading from one thread while another is modifying it or [...]. There is nothing memory safe whatsoever about std::vector<something> and std::string. Sure, they give you access to their allocated length, so they're better than something[] and char* (which often also know the size of their allocations, but refuse to tell you). | ||||||||
▲ | bluGill 7 months ago | parent [-] | |||||||
> going off the end of the vector with an iterator, The point of an iterator is to make it hard to do that. You can, but it is easy to not do that. > modifying the vector while iterating it Annoying, but in practice I've not found it hard to avoid. > adding to the vector from two different threads or reading from one thread while another is modifying it Rust doesn't help here - they stop you from doing this, but if threads are your answer rust will just say no (or force you into unsafe). Threads are hard, generally it is best to avoid this in the first place, but in the places where you need to modify data from threads Rust won't help. | ||||||||
|