lasso
lasso copied to clipboard
Added _yes get_or_intern methods
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.)
Oh, and obviously _yes
is a stupid name and we should call it something else.
And we need to confirm that this is the intuitive order in the returned tuple.
Tuple order is good, I think a name involving insert
would be good since that‘s similar to the HashMap api