-
Notifications
You must be signed in to change notification settings - Fork 734
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
Value
implementation for `Option<T> where T: Value
#878
Conversation
Signed-off-by: Eliza Weisman <[email protected]>
fix lifetime mismatch
implementation for
Option<T> where T: ValueValue
implementation for `Option<T> where T: Value
tracing-core/src/field.rs
Outdated
/// Visit an Option | ||
fn record_option(&mut self, field: &Field, value: Option<&(dyn Value + 'static)>) { | ||
if let Some(inner_value) = value { | ||
self.record_debug(field, &inner_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this implements the recording of the interior type using the appropriate type-specific record_*
method as described in the linked task.
You probably want to call the record
method on the inner_value
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right inner_value.record(field, self)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right
inner_value.record(field, self)
?
Yeah, that's right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this PR @humancalico.
I'd like to use it so I've made some suggestions that should hopefully make CI pass and unblock progress.
/// Visit an Option | ||
fn record_option(&mut self, field: &Field, value: Option<&(dyn Value + 'static)>) | ||
where | ||
Self: std::marker::Sized, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want to have a Self: Sized
constraint here because this trait is meant to be used with dynamic dispatch.
If you added it because of the borrow checker try using a reborrow (&mut *self
) to pass self
to inner_value.record()
.
if let Some(inner_value) = value { | ||
inner_value.record(field, self) | ||
} else { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this else { }
be removed if we aren't going to do anything with it? If a serializer cares about the lack of a value they can always override this method and do a match
themselves.
Thanks! @Michael-F-Bryan |
Obsoleted by #1585, sorry about that! |
Closes #824