【发布时间】:2015-02-12 02:36:12
【问题描述】:
注意此问题包含早于 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
【问题讨论】:
-
锈游戏笔中的这段代码:is.gd/IPkdU4