Constant konst::alloc_type::STRING_NEW
source · pub const STRING_NEW: String;
Available on crate feature
alloc
only.Expand description
An empty String
. Usable to construct a [String; N]
.
As of Rust 1.65.0, [String::new(); LEN]
is not valid, because String
isn’t copy,
but [STRING_NEW; LEN]
does work, like in the example below.
§Example
use konst::alloc_type::STRING_NEW;
const STRINGS: [String; 3] = [STRING_NEW; 3];
let mut strings = STRINGS;
strings[0].push_str("foo");
strings[1].push_str("bar");
strings[2].push_str("baz");
assert_eq!(strings, ["foo", "bar", "baz"]);