maciejhirsz / beef

Faster, more compact implementation of std::borrow::Cow
https://crates.io/crates/beef
Apache License 2.0
338 stars 17 forks source link

Export traits while still hiding the implementation details #54

Closed alexkazik closed 1 year ago

alexkazik commented 1 year ago

I'm working on https://crates.io/crates/ownable, a crate that helps with Cow. And I thought that I could also support beef (even though I've never used it so far).

But It's not possible to add a generic impl because Beef and Capacity are not exported.

This patch does export them, and hides the internal details in another trait.

There are a few todos, please say what you like and I'dd edit it:

Edit: the adaption for ownable is here: https://github.com/alexkazik/ownable/compare/main...beef

maciejhirsz commented 1 year ago

Thanks for this @alexkazik. Wondered why you need this but I see you just need to invoke the traits as markers to be able to define types.

Looks fine to me. Option 1 for impls looks good enough, less future-proof but faster for the compiler to reason about I suppose?

Happy to merge the PR without doc comments for the traits so I can add them later before publishing this, but feel free to add them.

alexkazik commented 1 year ago

I've updated the branch. And no need to hurry with a new release.

maciejhirsz commented 1 year ago

Cheers!