Why is this legal?
⚓ Rust 📅 2026-04-23 👤 surdeus 👁️ 3The implementation of binary heaps in std uses a Hole type. It stores a &mut [T], but one of the elements in this slice becomes temporarily invalid (it is repaired in the Drop implementation). Why is it okay to have a reference (as opposed to a pointer)? Does the existence of the reference imply the elements of the slice are valid? The code never reads the invalid element of the slice
6 posts - 4 participants
🏷️ Rust_feed