arrayvec icon indicating copy to clipboard operation
arrayvec copied to clipboard

Shrink unsafe blocks

Open peamaeq opened this issue 2 years ago • 1 comments

In these function you use the unsafe keyword for some safe expressions.

We need to mark unsafe operations more precisely using unsafe keyword. Keeping unsafe blocks small can bring many benefits. For example, when mistakes happen, we can locate any errors related to memory safety within an unsafe block. This is the balance between Safe and Unsafe Rust. The separation is designed to make using Safe Rust as ergonomic as possible, but requires extra effort and care when writing Unsafe Rust.

Hope this PR can help you. Best regards. References https://doc.rust-lang.org/nomicon/safe-unsafe-meaning.html https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html

peamaeq avatar Jun 23 '22 07:06 peamaeq

I don't see that this brings much benefit. The parts you moved outside of the unsafe blocks are part of the code that upholds the safety.

tbu- avatar Jun 23 '22 09:06 tbu-

Thanks and my thoughts echo what @tbu- said. While the PR's changes are correct and harmless, this is not a logic for updating unsafe code blocks that I believe in.

bluss avatar Nov 12 '22 09:11 bluss