Remove the need for allocation from is_utf8_string
.
#368
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.
Previously,
IsEncodedStringMatcher
converted its actual value input to aVec
and constructed aString
out of that in order to match it. This is because using a string slice caused problems with the borrow checker as described in #323.The fundamental problem is that the type against which the inner matcher is matching is a reference whose lifetime must be named in the trait bound:
One option is just to remove the reference:
This doesn't work when the inner matcher is
eq
, since one would then be comparing anstr
and a string slice:However, this problem does not occur with
StrMatcher
:So this also introduces an easy way to obtain a
StrMatcher
to check string equality:This is slightly inconvenient, since one must use a different matcher to compare string equality in this case. But it is well-documented and not too inconvenient to use. So it should be okay.
The introduction of
eq_str
also allows fixing a longstanding limitation of the matcherproperty!
-- that it could not match on properties returning string slices. This PR therefore also updates the documentation accordingly and adds an appropriate test.