包含 unsafe Rust 程式碼

根據預設,rust_static_library 中禁止使用不安全的 Rust 程式碼,系統也不會編譯這類程式碼。如果需要不安全的 Rust 程式碼,請在 gn 目標中加入 allow_unsafe = true (本課程稍後會說明必須這麼做的情況)。

import("//build/rust/rust_static_library.gni") rust_static_library("my_rust_lib") { crate_root = "lib.rs" sources = [ "lib.rs", "hippopotamus.rs" ] allow_unsafe = true }