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

Comparison to other "safe transmute" crates #1

Closed
8573 opened this issue Jul 21, 2022 · 5 comments
Closed

Comparison to other "safe transmute" crates #1

8573 opened this issue Jul 21, 2022 · 5 comments

Comments

@8573
Copy link

8573 commented Jul 21, 2022

In the spirit of

I suggest documenting how this crate compares with some other crates that offer "safe transmute" functions, especially for transmuting a type to itself, such as

@GoldsteinE
Copy link
Owner

Thanks for suggestion!

It looks like first two require to statically provide an equality proof, which could be impossible in some contexts — for example, when implementing a generic method of a foreign trait and arguably worse for usability: if you want to compare a type against several other types, you’ll need to carry an enum of Refls and match on it dynamically, which is not zero-cost.

I think the third one doesn’t provide equivalent functionality at all, but I’ll have to look further into it.

@GoldsteinE
Copy link
Owner

I’ll describe this in README a little bit later.

@zicklag
Copy link

zicklag commented Jul 29, 2022

Another crate we might want to compare with is castaway which seems by far the most similar so far, but also seems to lack the functionality of cismute::reference.

@GoldsteinE
Copy link
Owner

It can cast simple references, but it seems to not be extendable. Also it uses macros instead of functions, so reqiured bounds are explained in text, not in types. It also lacks switch.

Thanks, I’ll add this to the comparison.

@zicklag
Copy link

zicklag commented Jul 29, 2022

Ah. I ended up using your crate instead of it because I didn't want to have to implement LifetimeFree, especially because I had to implement it on a foreign container type, which meant I'd have to use a newtype, which would just end up with way more boilerplate.

I think I have a real-world use-case for your crate, so thanks a lot for this!

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

3 participants