Skip to content

Make it easier to create a Value from owned or erased external types#339

Merged
KodrAus merged 2 commits into
rust-lang:masterfrom
KodrAus:feat/value-slot
Jul 6, 2019
Merged

Make it easier to create a Value from owned or erased external types#339
KodrAus merged 2 commits into
rust-lang:masterfrom
KodrAus:feat/value-slot

Conversation

@KodrAus
Copy link
Copy Markdown
Contributor

@KodrAus KodrAus commented Jul 3, 2019

This PR allows consumers to work around Value's required lifetime constraints in two ways:

  1. allowing us to create a value with any lifetime from some owned primitive, like u8, bool etc. This is what the Primitive type is all about.
  2. allowing us to create a value from some type that can produce a concrete value we can use, but doesn't guarantee it will live as long as the value itself. This is what the Fill and Slot types are all about.

The Fill API is a more advanced initialization strategy (it's actually a kind of visitor that just tries very hard to look like initialization), so it isn't exported from the log::kv module. Instead, this PR makes the value module public and leaves Fill and Slot in there. We need something like this to be able to translate a &'kvs dyn tracing::Value into a log::kv::Value<'kvs>.

that means doing two things:

1. allowing us to create a value with any lifetime from some owned
primitive, like u8, bool etc
2. allowing us to create a value from some type that _can_ produce
a concrete value we can use, but doesn't guarantee it will live as
long as the value itself
@KodrAus
Copy link
Copy Markdown
Contributor Author

KodrAus commented Jul 3, 2019

I'll be a good citizen and add some tests for Fill...

@KodrAus KodrAus merged commit 9b71d36 into rust-lang:master Jul 6, 2019
@KodrAus KodrAus deleted the feat/value-slot branch July 6, 2019 01:41
EFanZh pushed a commit to EFanZh/log that referenced this pull request Jul 23, 2023
Co-authored-by: github-actions <github-actions@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant