Out of an const array with subarrays (where each item is a (usize, TestEnum)
tuple)...
#[derive(Debug)]
enum TestEnum {
AAA(bool),
BBB,
}
const ARRAY: &[(usize, &[TestEnum])] = &[
(0, &[TestEnum::AAA(true), TestEnum::BBB]),
(1, &[TestEnum::BBB])
];
dgb!(ARRAY); // works fine!
...I'm trying to create a BTreeMap
as below:
const BTREE: &BTreeMap<i32, &[PathSegment]> = &BTreeMap::from(ARRAY);
However, the the compiler is complaining:
the trait
From<&[(usize, &[TestEnum])]>is not implemented for
BTreeMap<_, _, _>`
Before I jump into the water of trying to implement the missing From trait:
- Is there a way to construct the const BTreeMap other than via the array of &-s that I am using above?
- If not 1, is it even possible to create such a const BTreeMap at all...?
- If i do need to implement the missing From trait, could you give me an assistance of where to start?
Other ideas?