-
Notifications
You must be signed in to change notification settings - Fork 20
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
Consider Visit::visit_key + Visit::visit_value #65
Comments
wdyt @taiki-e ? |
@KodrAus can you provide an example of a case where the key & value are not available at the same time or when we would need this separation to bridge an API? |
@carllerche Something I’ve had is when lazily parsing a value while only keeping a single token around at a time. That’s bespoke enough to reasonably suggest “not fit for purpose” for, but is something I’ve run into. For bridging, we’ve currently got |
The initial idea of valuable-serde had ToSerde (Serializable) and FromSerde, and IIRC this was needed when implementing FromSerde. In the end, only ToSerde (Serializable) was implemented, so it was deferred. However, I think this is one of the features needed to support "what serde supports", so I have no objection to adding this. |
The
Visit
trait has avisit_entry
method that accepts a key-value pair. In cases where you’re bridging different APIs you might not be able to guarantee both the key and value are present at the same time to pass to this method. For instance,serde::SerializeMap
treats entries as an optimization and requires serializers support receiving keys and values independently. We ended up adding these separate methods to the standard library’sfmt
builders for this reason.We could consider making
visit_entry
forward to some newvisit_key
andvisit_value
methods.The text was updated successfully, but these errors were encountered: