Normal Vec uses the unstable #[may_dangle] on its Drop impl, avoiding issues with lifetimes when a ArryaVec is used as a struct field and stores references to other fields of the struct. Smallvec has a feature flag to opt in to doing the same.
Playground with the problem: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=1ae3af28bff1fe47748f747755f47326
change ArrayVec to Vec to see that it works.
references/docs:
https://doc.rust-lang.org/nomicon/dropck.html#an-escape-hatch
https://std-dev-guide.rust-lang.org/tricky/may-dangle.html
Normal
Vecuses the unstable #[may_dangle] on its Drop impl, avoiding issues with lifetimes when a ArryaVec is used as a struct field and stores references to other fields of the struct. Smallvec has a feature flag to opt in to doing the same.Playground with the problem: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=1ae3af28bff1fe47748f747755f47326
change ArrayVec to Vec to see that it works.
references/docs:
https://doc.rust-lang.org/nomicon/dropck.html#an-escape-hatch
https://std-dev-guide.rust-lang.org/tricky/may-dangle.html