注意此問題包含早於Rust 1.0的語法。代碼無效,但概念仍然相關。如何創建一個靜態字符串數組?
如何在Rust中創建全局靜態字符串數組?
對於整數,這編譯:
static ONE:u8 = 1;
static TWO:u8 = 2;
static ONETWO:[&'static u8, ..2] = [&ONE, &TWO];
但我不能得到類似的東西字符串編譯:
static STRHELLO:&'static str = "Hello";
static STRWORLD:&'static str = "World";
static ARR:[&'static str, ..2] = [STRHELLO,STRWORLD]; // Error: Cannot refer to the interior of another static
此代碼在鏽圍欄:HTTP://是.gd/IPkdU4 – 2014-12-13 14:18:37