You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
351: Update Interoperability section r=eldruin a=abt8601
Following the discussion on #348, this PR proposes the following changes to the Interoperability section:
- Update descriptions regarding the availability of `core::ffi`.
- Remove mentions of `std::os::raw`.
I intentionally kept mentions of the `cty` crate and the `cstr_core` crate since the next section uses the former. We may also consider updating the following section to use `core::ffi` instead of the `cty` crate.
This PR also introduces two additional changes.
First, it changes the descriptions regarding the implicit conversion between C and Rust types. The book says that the compiler implicitly converts between the two types, but it doesn't sound right to say that the example (reproduced below) works because of the conversion. It works simply because, on platforms where `unsigned int` is 32-bit long, `c_uint` and `u32` are the same type because the former is a type alias of the latter. This PR also removes the `unsafe` from the example since I believe it plays no role.
```rust
unsafe fn foo(num: u32) {
let c_num: c_uint = num;
let r_num: u32 = c_num;
}
```
Second, it changes the text formatting in the type correspondence table. The types in the table now use code formatting. Also, the presentation of C pointer types is updated (e.g. `*char` → `char *`).
Closes#348.
Co-authored-by: Po-Yi Tsai <abt8601@protonmail.ch>
0 commit comments