8000 Make type_eq() const. · Issue #98 · facet-rs/facet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make type_eq() const. #98

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

Open
lonjil opened this issue Apr 10, 2025 · 3 comments
Open

Make type_eq() const. #98

lonjil opened this issue Apr 10, 2025 · 3 comments
Labels
🙅 blocked blocked on something else ✨ enhancement New feature or request

Comments

@lonjil
Copy link
lonjil commented Apr 10, 2025

I am trying to commit const fn crimes with Facet, and got stuck on type_eq() not being const. I understand that this might be annoying to implement since PartialEq::eq isn't const yet, but being able to dispatch on type in const fns would be very useful, so it may be worth investigating.

@fasterthanlime
Copy link
Contributor

I think I can make it work.

@fasterthanlime
Copy link
Contributor

Okay, so you can't make it work. The whole trick behind const TypeId is that it's actually grabbing the pointer and only evaluating it, or calling the function pointer that returns the TypeId when you're actually doing anything with it, like comparing it. So it actually relies on PartialEq not being const.

I suppose it could work on nightly only? but I'm really hesitant to step it into nightly territory because I have been trying very hard to make everything work on stable.

@fasterthanlime fasterthanlime added ✨ enhancement New feature or request 🙅 blocked blocked on something else labels Apr 10, 2025
@fasterthanlime
Copy link
Contributor

I tried nightly's "const_type_id" feature briefly and if it stabilizes, we're still blocked on requiring T: 'static, which locks us out of, for example, Vec<&str>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 blocked blocked on something else ✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants
0