Including unsafe Rust Code
默认情况下,禁止在 rust_static_library 中使用不安全的 Rust 代码,因为此类代码无法编译。如需使用不安全的 Rust 代码,请将 allow_unsafe = true 添加到 gn 目标中。(在本课程的稍后部分,我们将介绍在哪些情形下必须这样做。)
1. import("//build/rust/rust_static_library.gni")
3. rust_static_library("my_rust_lib") {
4. crate_root = "lib.rs"
5. sources = [
6. "lib.rs",
7. "hippopotamus.rs"
8. ]
9. allow_unsafe = true
10. }
