Open milibopp opened 7 years ago
This is a good issue! I can think of a few things in the standard library that are tempting but haven't been done yet for various reasons. Perhaps we can leave the issue open as a place for people to mention types they would like, or to read about why some things are hard. For example:
The Rc
type is pretty popular, but if abomonation exposes a &Rc<_>
backed by immutable data, then operations like clone()
will not actually succeed. They tweak a cell
wrapping the reference counts (strong/weak) and believe that this means memory will be kept around even after the source reference is discarded, which it will not.
The HashMap
type is pretty popular too, but currently its backing memory is a bit of a tangle (last time I checked: a raw pointer with some assumed structure, navigated carefully by the implementors). I don't think there is anything in the HashMap
signature that prevents exposing a &HashMap
backed by immutable data, I'm just not personally comfortable being the one that walks through the fields and sets things appropriately (e.g. if the key field has type String
we would need to visit each key and set their pointer appropriately, but HashMap
does not let you directly mutate keys, understandably).
By comparison, serde implements its Serialize trait for a lot more types than abomonation does. It might be a nice idea to gradually add more types from
std
to avoid ergonomic issues caused by missing implementations.To get started, I added a trivial implementation for
PhantomData
in #4, because I think it will help make integratingnalgebra
andabomonation
in sebcrozet/nalgebra#277 more ergonomic. Other types will likely be more work ;)