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.
Adds
get_or_intern_yes
,try_get_or_intern_yes
,get_or_intern_static_yes
,try_get_or_intern_static_yes
methods that return an additional boolean that answers questions like: "Was this a new, never before seen string?", "Am I the first person to receive this key?", "Should I go compile a Regex or other string derivative and store it in a keyed-alike collection eagerly?", etc.This allows doing additional things on the first time a string is seen, without hashing twice.
I updated the doctests to actually test the correctness of the bool returned, but didn't otherwise add tests.
I didn't touch the
Interner
trait because it's not sealed and adding the new methods to it would be a breaking change.(An honest default implementation would hash twice by calling
Resolver::contains_key
, not sure if that is something we'd want to publish.)