Pointer constness for FFI
⚓ Rust 📅 2025-11-13 👤 surdeus 👁️ 5Suppose I have an opaque C type MyType and a C function get_name(MyType* p), and I'm going to invoke the function from Rust. Logically the function doesn't change the internal state of p, but the implementation may require a mutable pointer.
In this case, what should be signature of the corresponding function in Rust? More specifically, should I use p: *const MyType or p: *mut MyType?
2 posts - 2 participants
🏷️ Rust_feed