How to create a static array of strings?

前端 未结 4 1247
情书的邮戳
情书的邮戳 2021-02-03 18:45

Note This question contains syntax that predates Rust 1.0. The code is invalid, but the concepts are still relevant.

How do

4条回答
  •  无人及你
    2021-02-03 19:50

    Another way to do it nowadays is:

    const A: &'static str = "Apples";
    const B: &'static str = "Oranges";
    const AB: [&'static str; 2] = [A, B]; // or ["Apples", "Oranges"]
    

提交回复
热议问题