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

Separate the FFI-safe types from the rest of the crate #79

Open
PonasKovas opened this issue Feb 4, 2022 · 6 comments
Open

Separate the FFI-safe types from the rest of the crate #79

PonasKovas opened this issue Feb 4, 2022 · 6 comments

Comments

@PonasKovas
Copy link

Hello, first of all, thanks for this amazing crate.

In my project, I find your #[repr(C)] equivalents of common types from std and such (RVec, RString, etc) very useful, however - everything else on this crate - not so much.

I was wondering if it would be possible to separate the abi_stable::std_types module to a separate crate, that would just provide #[repr(C)] types and a simple numerical ABI_VERSION constant. That would make things much simpler for my project (and others, my case is definitely not the only one), help compilation times and so on. Making modular libraries is always a good practice.

@PonasKovas
Copy link
Author

I have started working on my own, more minimal package that provides #[repr(C)] equivalents of common types: safe_types

@marioortizmanero
Copy link
Contributor

marioortizmanero commented Feb 15, 2022

Very interesting! I would still leave this open, since it would be a great idea in case someone has the time to do it. Though it would indeed be quite complicated, since sabi_types heavily relies on the macros. May I ask, how are you going to implement SCow so that you don't get the same issue as in #75? I think that's still pending, right?

@PonasKovas
Copy link
Author

I haven't implemented Cow yet, and it's not a priority for me, since I'm implementing things in the order that I need them in another project. When I get to it, I will look more into it.

@PonasKovas PonasKovas reopened this Feb 15, 2022
@marioortizmanero
Copy link
Contributor

I haven't implemented Cow yet, and it's not a priority for me, since I'm implementing things in the order that I need them in another project. When I get to it, I will look more into it.

No problem, just make sure it's not invariant when you write it, or you'll run into problems. Your already implemented RVec<T> should use NonNull<T> instead of *mut T for the same reason.

@PonasKovas
Copy link
Author

@marioortizmanero If you're still interested,

I implemented Cow in my safe_types. I haven't looked at your implementation in depth, but on the first glance it looks like I took a different approach.

@marioortizmanero
Copy link
Contributor

marioortizmanero commented Apr 3, 2022

Nice! Yeah, different design, but I think you don't have the invariance issues with it. Our design ended up being quite similar, but I would say ours is a bit more flexible, at the cost of being harder to implement/use.

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