Guest User

Untitled

a guest
May 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. // How to add an element to the accumulator acc and move out?
  2.  
  3. .fold(|| HashMap::new(), | mut acc: HashMap<Hash, Group>, (idx, hash) | {
  4. {
  5. let e = acc.entry(hash)
  6. .or_insert(Group {value: Vec::new(), pos: group.pos + CHUNK_SIZE as u64, size: group.size });
  7. (*e).value.push(*idx);
  8. }
  9. acc
  10. })
  11.  
  12. // compiler output
  13. error[E0505]: cannot move out of `acc` because it is borrowed
  14. --> src/main.rs:114:13
  15. |
  16. 111 | let e = acc.entry(hash)
  17. | --- borrow of `acc` occurs here
  18. ...
  19. 114 | acc
  20. | ^^^ move out of `acc` occurs here
  21.  
  22. error: aborting due to previous error
Add Comment
Please, Sign In to add comment