mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-20 14:31:15 +02:00
parent
2bae363d16
commit
64bd331314
src/android
@ -8,3 +8,15 @@ that you can:
|
||||
|
||||
When you call functions in a foreign language we say that you're using a
|
||||
_foreign function interface_, also known as FFI.
|
||||
|
||||
<details>
|
||||
|
||||
- This is a key ability of Rust: compiled code becomes indistinguishable from
|
||||
compiled C or C++ code.
|
||||
|
||||
- Technically, we say that Rust can be compiled to the same [ABI] (application
|
||||
binary interface) as C code.
|
||||
|
||||
</details>
|
||||
|
||||
[ABI]: https://en.wikipedia.org/wiki/Application_binary_interface
|
||||
|
@ -24,3 +24,17 @@ We already saw this in the
|
||||
> production.
|
||||
|
||||
We will look at better options next.
|
||||
|
||||
<details>
|
||||
|
||||
- The [`"C"` part][extern-abi] of the `extern` block tells Rust that `abs` can
|
||||
be called using the C [ABI] (application binary interface).
|
||||
|
||||
- The `safe fn abs` part tells that Rust that `abs` is a safe function. By
|
||||
default, extern functions are considered unsafe, but since `abs(x)` is valid
|
||||
for any `x`, we can declare it safe.
|
||||
|
||||
</details>
|
||||
|
||||
[extern-abi]: https://doc.rust-lang.org/reference/items/external-blocks.html#abi
|
||||
[ABI]: https://en.wikipedia.org/wiki/Application_binary_interface
|
||||
|
Loading…
x
Reference in New Issue
Block a user