Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jul 6, 2019

Conversation

KodrAus
Copy link
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
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