Git clone my code here: https://github.com/LixurProtocol/Lixur and open the chain.rs file in chain -> src -> chain.rs.
The error I am getting on line 180 and on line 185 is the following:
error[E0382]: use of moved value: `chain`
--> src/chain.rs:185:26
|
180 | fn generate_chain_genesis_transactions (chain: Vec<(String, Transaction)>) {
| ----- move occurs because `chain` has type `Vec<(std::string::String, Transaction)>`, which does not implement the `Copy` trait
...
185 | make_transaction(chain, keys_one.2, keys_two.2, 0.0, signature.1);
| ^^^^^ value moved here, in previous iteration of loop
Things I have tried (That haven't worked)
- Removing the
make_transactionfunction out of the loop and copying it three times - Using
chain.clone(), only shows one transaction in thechain.jsonfile. - Trying to see if I could implement the Copy Trait. Impossible to do due to using the
Stringtype. - Trying to replace the
Vec<(std::string::String, Transaction)>type with a struct called Chain, which had those as its parameters and tried to implement Copy, didn't work.
Is there a way to go around this?
fn foo(t: T)andfn foo(t: &T)? The first time you iterate the value has been moved into themake_transactionfunction, because i) you aren't passing a reference and ii) it doesn't implementCopy. The second time it's no longer available. - corinjg