ascent icon indicating copy to clipboard operation
ascent copied to clipboard

Unsoundness in `util::update`

Open dfoxfranke opened this issue 2 years ago • 1 comments

ascent_base::util::update is unsound, because the value will be left in an inconsistent state if the update function panics.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8483c2bae0a8e0aa486d7bdf2fe1e780

The crate replace_with provides a safe way to implement this idiom.

dfoxfranke avatar Apr 30 '24 15:04 dfoxfranke

Thanks for bringing up the issue! I'll either follow your suggestion and use replace_with instead of update, or change impls of Lattice to not need to call update at all.

s-arash avatar May 01 '24 21:05 s-arash