注意此问题包含早于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