-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add a TypeID
intrinsic
#9913
Comments
Nominating. |
Comparing I know unique names of types across different crates are tricky, but even if given only the unique name within the defining crate, this would be extremely useful for debugging dynamic type errors. |
I don't think that the type id is the right location for the name, but there is a |
Fair point... that said, it seems silly we have |
That's not a bad idea unifying them. I think right now the blocker for that is that |
…akis This isn't quite as fancy as the struct in #9913, but I'm not sure we should be exposing crate names/hashes of the types. That being said, it'd be pretty easy to extend this (the deterministic hashing regardless of what crate you're in was the hard part).
…akis This isn't quite as fancy as the struct in #9913, but I'm not sure we should be exposing crate names/hashes of the types. That being said, it'd be pretty easy to extend this (the deterministic hashing regardless of what crate you're in was the hard part).
It's needed for things like an
Any
type, or safe dynamic loading.It basically needs to be an generic intrinsic that returns some kind of data structure that uniquely identifies the generic type it has been instantiated with. Ideally it also includes information about the crate itself and it's meta data, so that two different named and/or versioned crates with the same type result in different
TypeID
s.Currently, the static pointers to type descriptors can be kinda used for this, but there is no guarantee that a type descriptor can not be duplicated, so using them for this purpose is incorrect.
Possible usage could look like this:
See also https://gist.github.com/Kimundi/6802198 for some prototype implementation of a
TypeID
using type descriptors.The text was updated successfully, but these errors were encountered: