mirror of
https://github.com/nkbai/book.git
synced 2026-08-24 20:23:29 +08:00
Merge #51
51: Fix a bit of broken markdown in the interop chapter r=jamesmunns a=jamesmunns Co-authored-by: James Munns <james.munns@ferrous-systems.com>
This commit is contained in:
@@ -19,14 +19,13 @@ to C-types that are easier and safer to handle.
|
||||
For `#![no_std]` environments, there is also `core::raw` that
|
||||
covers all the primitive types.
|
||||
|
||||
------------------------------------------
|
||||
| Rust type | Intermediate | C type |
|
||||
|-----------|--------------|--------------|
|
||||
| String | CString | *char |
|
||||
| &str | CStr | *const char |
|
||||
| () | c_void | void |
|
||||
| u32 | u64 | c_uint | unsigned int |
|
||||
| etc | ... | ... |
|
||||
| Rust type | Intermediate | C type |
|
||||
|------------|--------------|--------------|
|
||||
| String | CString | *char |
|
||||
| &str | CStr | *const char |
|
||||
| () | c_void | void |
|
||||
| u32 or u64 | c_uint | unsigned int |
|
||||
| etc | ... | ... |
|
||||
|
||||
As mentioned above, primitive types can be converted
|
||||
by the compiler implicitly.
|
||||
@@ -36,4 +35,4 @@ unsafe fn foo(num: u32) {
|
||||
let c_num: c_uint = num;
|
||||
let r_num: u32 = c_num;
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user