You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the title says, back_to_the_buffer can not easily be used from within another back_to_the_buffer call, which makes it hard to serialize some nested formats.
The default/recommended way to use back_to_the_buffer would be to use gen(<serializer>) inside the gen closure like in the docs.
However, this wraps buf in a second WriteContext, so that the serializer is called with a WriteContext<WriteContext<W: Write + BackToTheBuffer>>.
With this, we can no longer call back_to_the_buffer again, since it requires a WriteContext<W: Write + BackToTheBuffer>.
It took me quite a while to come up with this solution: (adapted to the doc example)
Now back_to_the_buffer could be called again in the stringcombinator.
Could this be fixed/made easier in a nice way?
If not, maybe this example could at least be added to the docs so that others don't run into the same wall as I did.
Thanks!
The text was updated successfully, but these errors were encountered:
As the title says,
back_to_the_buffer
can not easily be used from within anotherback_to_the_buffer
call, which makes it hard to serialize some nested formats.The default/recommended way to use back_to_the_buffer would be to use
gen(<serializer>)
inside thegen
closure like in the docs.However, this wraps
buf
in a secondWriteContext
, so that the serializer is called with aWriteContext<WriteContext<W: Write + BackToTheBuffer>>
.With this, we can no longer call
back_to_the_buffer
again, since it requires aWriteContext<W: Write + BackToTheBuffer>
.It took me quite a while to come up with this solution: (adapted to the doc example)
Now
back_to_the_buffer
could be called again in thestring
combinator.Could this be fixed/made easier in a nice way?
If not, maybe this example could at least be added to the docs so that others don't run into the same wall as I did.
Thanks!
The text was updated successfully, but these errors were encountered: