Closed frozenspider closed 8 months ago
https://doc.rust-lang.org/nomicon/exception-safety.html
struct Hole<'a, T: 'a> { data: &'a mut [T], /// `elt` is always `Some` from new until drop. elt: Option<T>, pos: usize, } impl<'a, T> Hole<'a, T> { // ... unsafe fn get(&self, index: usize) -> &T { &self.data[index] } // ... }
Why is get here marked as unsafe? It doesn't seem to be performing anything particularly unsafe, any more so than regular safe code might do. Rust compiler also doesn't require it to be unsafe.
get
unsafe
I guess it was just missed when writing, a PR is welcome!
https://doc.rust-lang.org/nomicon/exception-safety.html
Why is
get
here marked asunsafe
? It doesn't seem to be performing anything particularly unsafe, any more so than regular safe code might do. Rust compiler also doesn't require it to beunsafe
.