Skip to content

Shrink unsafe block#244

Open
cactter wants to merge 1 commit intoLea-fish:mainfrom
cactter:main
Open

Shrink unsafe block#244
cactter wants to merge 1 commit intoLea-fish:mainfrom
cactter:main

Conversation

@cactter
Copy link
Copy Markdown

@cactter cactter commented Jul 21, 2022

In this function you use the unsafe keyword for almost the entrie function body.

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

@PureTryOut
Copy link
Copy Markdown
Collaborator

Thanks @cactter! However seems CI fails on the formatting check. Could you fix it?

@terrarier2111
Copy link
Copy Markdown
Member

Thanks @cactter! However seems CI fails on the formatting check. Could you fix it?

I am currently rewriting our entire rendering code to use wgpu-mc, so i don't think this is worth while as all unsafe code which was shrunk is part of said rendering part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants