&im::HashMap to im::HashMap

  1. I believe &im::HashMap -> im::HashMap should be very cheap, no more expensive than a Rc::clone()

  2. I can’t figure out how to do the above.

  3. Looking at https://docs.rs/im/12.3.3/src/im/hash/map.rs.html#596-600 there are functions which take a &im::HashMap , does an update, and returns a im::HashMap

  4. Now, suppose I want to do a number of these updates in sequence, I’d like to do:

let mut x: im::HashMap<...> = ...;
for ...
  x = x.update(...)

but I can’t do this right now because I can’t figure out how to convert an &im::hashMap to a im::HashMap


1 Like

@sfackler : tried that already. Clone not implemented. :frowning:


1 Like

You’re right. Problem is my Value type did not have impl Clone, so I couldn’t use that.

This also confuses me now – in a persistent hashmap, if everything is shared, why does the value type need to support Clone at all?

It does look like those K: Clone, V: Clone are both unnecessary. It only needs to clone the root with either Ref = Rc or Arc.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.