In https://doc.rust-lang.org/nomicon/exception-safety.html I suspect that self.ptr().add(i).write(x.clone()); is wrong. i is the position of x in to_push. We don't want to put x at position i as it would overwrite an already existing value. Instead we want it at position i+initial_length.
At least I assume. I don't understand how to find the documentation of ptr(), I don't see it in https://doc.rust-lang.org/stable/std/vec/struct.Vec.html . But I can't figure out a semantic off "add" where it makes sens to take "i"
In https://doc.rust-lang.org/nomicon/exception-safety.html I suspect that
self.ptr().add(i).write(x.clone());
is wrong.i
is the position ofx
into_push
. We don't want to putx
at positioni
as it would overwrite an already existing value. Instead we want it at positioni+initial_length
. At least I assume. I don't understand how to find the documentation ofptr()
, I don't see it in https://doc.rust-lang.org/stable/std/vec/struct.Vec.html . But I can't figure out a semantic off "add" where it makes sens to take "i"