Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Not sure at all, but I would try using as_mut on the options I guess. Doubtful it'll work the whole way though. Commented Jul 22, 2021 at 18:06
  • Thanks for the tip, and I did try using as_mut. However i kept running into this error: temporary value dropped while borrowed, consider using a 'let' binding to create a longer lived value This does not work: docs[0].as_hash().as_mut().unwrap(); Am I using as_mut incorrectly? I think unwrap may be to blame here? Commented Jul 22, 2021 at 18:52
  • unwrap would be causing the errors. But I'm not sure what to do here... The other possibilty would be to use an if let or a match to take out the values? Commented Jul 22, 2021 at 19:03
  • after playing around a bit more. It seems 'as_hash' always returns an immutable borrow. The library also exposes into_hash(), but it looks like this attempts to move it. Commented Jul 22, 2021 at 19:15
  • Thanks for pointing me in the direction of match. Using this in combination with borrow_mut seems to be doing exactly what I was looking for. From what I can tell this should avoid duplicating any data in memory now correct? Commented Jul 22, 2021 at 20:13