3 ms·
Unsafe blocks are subject to the same borrow checking that the rest of the language is.
by gmueckl 3y ago
Unsafe blocks are subject to the same borrow checking that the rest of the language is.
- tialaramex 3y agoThat is correct. However, raw pointers are not borrow checked, in safe Rust they're largely useless, but in unsafe Rust you can use raw pointers if that's what you need to do to get stuff done. As an example inside a String is just a Vec<u8> and inside the Vec<u8> is a RawVec<u8> and that is just a pointer, either to nothing in particular or to the bytes inside the String if the String has allocated space for one or more bytes - plus a size and a capacity.