Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementations for standard library types #5

Open
milibopp opened this issue Aug 14, 2017 · 1 comment
Open

Implementations for standard library types #5

milibopp opened this issue Aug 14, 2017 · 1 comment

Comments

@milibopp
Copy link
Contributor

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 integrating nalgebra and abomonation in dimforge/nalgebra#277 more ergonomic. Other types will likely be more work ;)

@frankmcsherry
Copy link
Member

frankmcsherry commented Aug 14, 2017

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:

  1. 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.

  2. 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants