error-stack
expose Frame::type_id
#1289
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🌟 What is the purpose of this PR?
While developing
deer
(which heavily useserror-stack
andFrame
s for errors), I often tried to get the current type contained in aFrame
, before #1288error-stack
had apub(crate)
function with the same name (type_id
). Even thougherror-stack
no longer directly usesTypeId
, I think it is still valuable to add the method for lower-level use cases outside oferror-stack
, to inspect the contained type easily.This is entirely optional, one can also repeatedly call
Frame::is<T>()
for every expected type, but this isn't ideal, as it isn't very straightforward, nor ergonomic, or as performant as a simple lookup in aHashSet
(or similar).🔍 What does this change?
Frame::type_id
📜 Does this require a change to the docs?
Yes, the newly exposed method is documented.
❓ How to test this?
An additional test has been added to verify the behavior.