-
Notifications
You must be signed in to change notification settings - Fork 7
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
Improve the Error
type
#4
Conversation
I'll review everything else later, but
I was thinking about this and one way around that would be to have associated string-typed constants in a trait that is implemented on the types we care about. And then either make the error type generic (hmm), or store the Not that nice but nicer than the error messages without nightly IMHO :) |
In a way that works too, but that is also suboptimal in a way - eventually the (If only specialization was stable we could hide the trait as an implementation detail, but alas, that also in unstable.) It's up to you though which approach you'd like to go for. (: (I'm fine either way as long as the traits will still be implementable outside the crate.) |
Do you know what the plan for stabilizing |
Looking at the comments on the issue it's.... somewhat hard to tell. Your guess is probably as good as mine. It could probably be stabilized sooner (it's not a super complex feature) rather than later if someone could champion it, write a proper RFC and do all of the legwork, but there doesn't seem to be anyone like that right now. |
Then it seems ok to me to add a trait for this for now, and once it became stable we remove that trait again. It breaks backwards compatibility but will be very easy to update and probably won't affect most code out there at all. |
Okay. I'll update the PR tomorrow. |
Great, thanks :) |
77fdfed
to
ff46c72
Compare
Okay, you were right. It's definitely better to just use a trait, and since we can make it private it actually doesn't introduce any backward compatibility hazards. I've also updated the changelog. Please let me know if you'd like anything else changed. |
But if it's private, how would you make this crate work on custom types? I thought that was one of your requirements :) |
Yeah, that was a little brainfart on my part. (: As long as the |
Indeed, I missed that little detail too. Nice :) Thanks a lot! |
@koute Do you have any other breaking changes you'd like to do before I do a release? |
I don't have anything else planned at the moment, so you can go ahead with the release. (: |
Ok great, I'll probably get to that this weekend. Thanks again |
Thanks! |
Published on crates.io now :) |
So there are a few things I want to point out:
and like this:
I've added a disabled-by-default feature
nightly
which can be used by the user to enable the use oftype_name
and get the actual type name in the error message.With the feature enabled those two error messages look like this:
and:
Hopefully once
type_name
stabilizes we can just make this the default and make thenightly
feature a no-op.