(Move) push_back on nested vector

79 Views Asked by At

I have a data type defined as

let digests: vector<vector<u8>>;

In this digests vector if I try to use push_back to insert another vector as the following

let digest1: vector<u8>;
let digests: vector<vector<u8>>;

digest1 = h"00";
digests = Vector.empty<vector<u8>>();

Vector.push_back<vector<u8>>(
                &mut digests, 
                copy(digest1)
            );

The tests fail on push_back with the following error.

[106] DiscardedTransaction(TransactionOutput { write_set: WriteSet(WriteSetMut { write_set: [] }), events: [], gas_used: 0, status: Discard(VMStatus { major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR, sub_status: None, message: Some("vector elem type mismatch -- expected Vector(U8), got General([])") }) })

I am a bit lost with this error. Also, are there any better alternatives to implement a nested vector?

I am using move intermediate representation to write the above

1

There are 1 best solutions below

0
On