1. 7

  2. 1

    I have to say, this post didn’t give me the best impression of the author. They are clearly new to Rust and don’t understand why a lot of decisions were made but are strongly asserting about their opinions without comparing them to the actual reasons that things are that way. Of course lots of the complaints are valid but still the way it was presented and that these interactions didn’t strike me as the best attitude.

    A C function call is by definition “unsafe”, I shouldn’t have to tell the Rust compiler that.

    This is completely missing the point. Of course the compiler knows, that is how it can raise an error. This is letting your teammates know that this code is potentially dangerous and needs to be treated with more care when reviewing and modifying it.

    But yes, I can imagine that if you are dealing with a lot of C FFI it can feed tedious. Generally the best approach here is to isolate C FFI into a small region of your code and write safe wrappers around commonly used functions. Of course if you are consuming a huge API service this also gets tedious fast.