Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust unsafe blocks for the Drop impl #138

Merged
merged 1 commit into from
Jun 16, 2022
Merged

Conversation

peamaeq
Copy link
Contributor

@peamaeq peamaeq commented May 18, 2022

No description provided.

@jeromefroe
Copy link
Owner

@peamaeq the change looks good to me, I was just curious about the motivation for it? Was this just a formatting change or was there another reason behind it?

@peamaeq
Copy link
Contributor Author

peamaeq commented Jun 16, 2022

@peamaeq the change looks good to me, I was just curious about the motivation for it? Was this just a formatting change or was there another reason behind it?

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.
References
https://doc.rust-lang.org/nomicon/safe-unsafe-meaning.html
https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html

@jeromefroe
Copy link
Owner

@peamaeq makes sense, thanks for the contribution!

@jeromefroe jeromefroe merged commit 8d2d94c into jeromefroe:master Jun 16, 2022
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.

2 participants