json-rust
json-rust copied to clipboard
Can't take ownership of object entries
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.
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.