I found numerous answers related to converting vectors into arrays, but all deal with simple types inside the vector, which in my case doesn't work.
I have a Vec<(String, PayloadType)>
where PayloadType
is a rich enum.
I need to convert it into an array [(String, PayloadType), _]
.
Some attempts:
try_into()
:
492 | Payload::from(v[..].try_into().unwrap())
| ^^^^^^^^ the trait `TryFrom<&[(String, mpl_token_auth_rules::payload::PayloadType)]>` is not implemented for `[(String, mpl_token_auth_rules::payload::PayloadType); _]`
into_inner()
:
492 | Payload::from(v.into_inner().unwrap())
| ^^^^^^^^^^ method not found in `Vec<(String, mpl_token_auth_rules::payload::PayloadType)>`
What's the right way to do it?
PS, the broader goal is to convert a hashmap like this:
pub struct Payload {
map: HashMap<String, PayloadType>,
}
into an array like this:
[(String, PayloadType); N]
I went about it by converting it to Vec first, but open to a better way.