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

Missing trait implementations #40

Open
17 tasks
Luro02 opened this issue Apr 18, 2020 · 1 comment
Open
17 tasks

Missing trait implementations #40

Luro02 opened this issue Apr 18, 2020 · 1 comment

Comments

@Luro02
Copy link

Luro02 commented Apr 18, 2020

There are some traits missing for StableVec that could be implemented.

Important traits:

  • Hash
  • Ord
  • Write
  • RefUnwindSafe
  • UnwindSafe
  • PartialOrd

serdes Serialize and Deserialize could also be supported?

Convenience:

  • From<BTreeMap<usize, T>>
  • Extend<&'a T>
  • From<&'_ str>
  • From<BinaryHeap<T>>
  • From<Box<[T]>>
  • From<CString>
  • From<String>
  • From<Cow<'a, [T]>>
  • PartialEq<&'_ [B; N]>
  • PartialEq<&'_ mut [B]>
  • PartialEq<[B; N]>
@LukasKalbertodt
Copy link
Owner

This crate is deliberately low level; API convenience is not particularly high on the priority list. Of course, if adding an impl makes sense and has a low maintenance cost, we can add it.

Ord, PartialOrd

I think it's not completely obvious how those would be implemented. Just use the filled slots for comparison? This could easily lead to confusion and subtle bugs. I think I prefer not to implement those.

Hash

Since StableVec implements PartialEq, we need to uphold the property k1 == k2 -> hash(k1) == hash(k2). And our PartialEq impl currently does this: "empty slots, capacity, next_push_index and the indices of elements are all checked. In other words: all observable properties of the stable vectors need to be the same for them to be equal."

So implementing Hash might be non-trivial.

RefUnwindSafe and UnwindSafe

Those are in a strange place right now. I already read proposals to deprecated them.

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