Do you think this comment is useful? For me, if names start with put it is obvious that these are a part of put, but feel free to keep it if it's useful for you.
It would be great if we could avoid having unsafe at function level, so that safe code could call it. I prefer having unsafe sections as small as possible, so maybe we can have an unsafe block in the function instead of the whole unsafe function?
pointer argument requires that the function be marked unsafe
I assume we have to mark these functions unsafe. I don't fully understand your concern, they're about to be called from c++ exclusively and I didn't notice any impact of unsafe on how we call them in c++ really. And I don't think we'll want to use them from rust.
I don't fully understand your concern, they're about to be called from c++ exclusively and I didn't notice any impact of unsafe on how we call them in c++ really.
The issue is not on C++ side but on the Rust one. If we mark the function as unsafe, we can use unsafe operations in the whole function. According to the book:
People are fallible, and mistakes will happen, but by requiring these five unsafe operations to be inside blocks annotated with unsafe you’ll know that any errors related to memory safety must be within an unsafe block. Keep unsafe blocks small; you’ll be thankful later when you investigate memory bugs.
It is a good practice to keep unsafe blocks as small as possible.