Why is this legal?
@user16251
·
2026-04-24
·
via The Rust Programming Language Forum - Latest posts
The 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
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。