Adding safety comments for unsafe impl Send/Sync

Hello everyone!

Question: Is it good practice / idiomatic to also add SAFETY comments for every unsafe impl Send/Sync? The reason I'm asking: I feel like if a struct is only !Send/!Sync by default due to a raw pointer, then the necessary SAFETY comemnts should rather go to those places where these raw pointers are dereferenced. But not sure if that's good practice?

1 Like

I consider it a good practice. Safety comments are for people to read to gain knowledge about the reasoning. Adding it at unsafe impl Send/Sync gives readers a quick picture of what's happening. And it's easier than going though all dereferencing places.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.