From 41d483ee5f452d6db3537f4086d50b326d169bb6 Mon Sep 17 00:00:00 2001 From: Zheng Ping Date: Tue, 4 Jul 2017 13:20:41 +0800 Subject: [PATCH] Update ch19-01-unsafe-rust.md --- src/ch19-01-unsafe-rust.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ch19-01-unsafe-rust.md b/src/ch19-01-unsafe-rust.md index 38547b3..29af074 100644 --- a/src/ch19-01-unsafe-rust.md +++ b/src/ch19-01-unsafe-rust.md @@ -193,10 +193,7 @@ let slice = unsafe { #### 调用外部代码的`extern`函数是不安全的 -有时, 你的Rust代码需要与其它语言交互. Rust有一个`extern`关键字可以实现这个功能, 这有助于创建并使用*外部功能接口(Foreign Function Interface)* (FFI). 例19-8 demonstrates how -to set up an integration with a function named `some_function` defined in an -external library written in a language other than Rust. Functions declared -within `extern` blocks are always unsafe to call from Rust code: +有时, 你的Rust代码需要与其它语言交互. Rust有一个`extern`关键字可以实现这个功能, 这有助于创建并使用*外部功能接口(Foreign Function Interface)* (FFI). 例19-8演示了如何与定义在一个非Rust语言编写的外部库中的`some_function`进行交互. 在Rust中调用`extern`声明的代码块永远都是不安全的: Filename: src/main.rs @@ -210,7 +207,7 @@ fn main() { } ``` -Listing 19-8: Declaring and calling an `extern` function +例19-8: Declaring and calling an `extern` function defined in another language Within the `extern "C"` block, we list the names and signatures of functions