]> git.lizzy.rs Git - rust.git/commitdiff
improve linked list -> drop transition
authorRalf Jung <post@ralfj.de>
Tue, 19 Feb 2019 20:23:53 +0000 (21:23 +0100)
committerRalf Jung <post@ralfj.de>
Tue, 19 Feb 2019 20:23:53 +0000 (21:23 +0100)
src/libcore/pin.rs

index 5056005bcd773ecddcbcff42f9d3eb288f82cd11..68213ab01537f4bc11807f77e779f1c142aabff4 100644 (file)
 //! list element will patch the pointers of its predecessor and successor to remove itself
 //! from the list.
 //!
-//! To make this work, it is crucial that we can actually rely on `drop` being called.
-//! And, in fact, this is a guarantee that `Pin` provides.
+//! Crucially, we have to be able to rely on `drop` being called. If an element
+//! could be deallocated or otherwise invalidated without calling `drop`, the pointers into it
+//! from its neighbouring elements would become invalid, which would break the data structure.
+//!
+//! This is why pinning also comes with a `drop`-related guarantee.
 //!
 //! # `Drop` guarantee
 //!
 //! off of a vector.
 //!
 //! This is exactly the kind of guarantee that the intrusive linked list from the previous
-//! section needs to function correctly. Clearly, if an element
-//! could be deallocated or otherwise invalidated without calling `drop`, the pointers into it
-//! from its neighbouring elements would become invalid, which would break the data structure.
+//! section needs to function correctly.
 //!
 //! Notice that this guarantee does *not* mean that memory does not leak! It is still
 //! completely okay not to ever call `drop` on a pinned element (e.g., you can still