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

Use transparent representation to allow casts #46

Closed
Plecra opened this issue Aug 3, 2020 · 4 comments
Closed

Use transparent representation to allow casts #46

Plecra opened this issue Aug 3, 2020 · 4 comments

Comments

@Plecra
Copy link

Plecra commented Aug 3, 2020

A repr(transparent) annotation would allow users to (soundly) cast pointers to Ts to UniCase<T>s. This is handy when you can't trivially dereference the pointer, which can come up in generic code.

@ijackson
Copy link

This is not trivial, sadly. A UniCase<T> actually contains an enum, so that it can represent whether the contained object is pure-ascii or not, for optimisation purposes. So a UniCase<T> cannot be cast back and forth with a T since the representation is actually different.

@Plecra
Copy link
Author

Plecra commented May 13, 2021

Ahw, that's a shame. Nevermind then

@Plecra Plecra closed this as completed May 13, 2021
@ijackson
Copy link

But see #49

@aQaTL
Copy link

aQaTL commented Jan 5, 2022

How about adding repr(transparent) to unicase::Ascii then?
I understand it could seem unintuitive to have it on Ascii, but not on Unicase, but it would be useful for people that want it to use it as a HashMap key and only care about ascii strings. At least until #49 is merged.

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