json-rust icon indicating copy to clipboard operation
json-rust copied to clipboard

Can't take ownership of object entries

Open SOberhoff opened this issue 7 years ago • 1 comments

I'm trying to iterate through the entries of an object (that I own) and consume them. However I'm only able to get borrowed access to the entries. Since I own the parent object I'd expect to be able to get ownership of its entries too somehow.

SOberhoff avatar Sep 24 '18 16:09 SOberhoff

Hi,

Object is a map. In Rust, a map has ownership of all entries. If you use a map, you're borrowing its content (entries). So if you want to take ownership, you can remove the entries via ::remove() function.

I hope this might help.

ghost avatar Oct 06 '18 19:10 ghost