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

Merged
KodrAus merged 2 commits from feat/value-slot into master 2019-07-05 20:41:33 -05:00
KodrAus commented 2019-07-03 17:04:26 -05:00 (Migrated from github.com)

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>.

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>`.
KodrAus commented 2019-07-03 17:29:32 -05:00 (Migrated from github.com)

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

I'll be a good citizen and add some tests for `Fill`...
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-rust-lang/log!339
No description provided.