udoprog / OxidizeBot

High performance Twitch bot in Rust
https://setbac.tv
Apache License 2.0
153 stars 22 forks source link

Shrink unsafe blocks #142

Closed cactter closed 1 year ago

cactter commented 2 years ago

In this 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

udoprog commented 2 years ago

Would you mind formatting your code (cargo fmt)? There should be a CI check for it, but this project has an old configuration ;)