Change Tag to hold a String instead of Cow<str> #52
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 does this PR do?
Change
Tag
to hold aString
instead ofCow<str>
.I also implemented
AsRef<str>
forTag
.Motivation
This originated from a lint on nightly which didn't like
Cow::to_owned
being called, and instead callers should use
Cow::clone
orCow::into_owned
. However, while inspecting the code with fresh eyes, wesaw that we're always holding a
Cow::Owned
variant, so just hold theString
instead.Simultaneously, I got a crash report in Rust for the PHP profiler. I
don't support forking, and they forked. Anyway, for this particular
crash it's not much harder to support
fork
(well, it leakstechnically but works) than to disable everything on a fork. As part of
supporting fork, I need to fixup the
process_id
tag to have the newpid after a fork, and
Tag::as_ref
will help with that.Additional Notes
I also noticed that we were fully qualifying two usages of
DateTime
andUtc
even though we're publicly using those, so I shortened them.How to test the change?
If your code is calling
Tag::to_owned
then it will break. It should bereworked into using a
Tag::clone
or call.to_string
on it or similar.