How do I initialize a BTreeMap
within a const
struct?
use std::collections::BTreeMap;
struct Book {
year: u16,
volume: u8,
amendment: u8,
contents: BTreeMap<String, String>,
}
const BOOK1: Book = Book {
year: 2019,
volume: 1,
amendment: 0,
contents: BTreeMap::new(), // Issue here
};
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:14:15
|
14 | contents: BTreeMap::new(),
| ^^^^^^^^^^^^^^^