r/rust • u/TheProgrammar89 • Jul 26 '19
Is this comment about the reference counting performance in Rust accurate?
/r/ProgrammerHumor/comments/b274zp/oof/eirvecs?context=3
53
Upvotes
r/rust • u/TheProgrammar89 • Jul 26 '19
View all comments
Show parent comment
1
u/Manishearth servo · rust · clippy Jul 27 '19
Every C++ container has to manually implement a drop flag (usually representable by a null state) which sometimes shows up in the final codegen.
Rust only generates then when necessary (rarely).
Duplicating the postlude doesn't work. The following is valid Rust:
The drop has to run at the end of the function because you can hold references to the vector.
See https://manishearth.github.io/blog/2017/04/13/prolonging-temporaries-in-rust/ , this is a useful technique.
because of this Rust needs a drop flag anyway, so also doing the postlude thing doesn't really get us anything.