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

Provide access to the underlying container of writers in the common case #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hsivonen
Copy link
Contributor

@hsivonen hsivonen commented Jan 5, 2017

(As discussed on IRC many weeks ago.)

When StringWriter is a String, provide access to the String.
When ByteWriter is a Vec<u8>, provide access to the Vec<u8>.

This allows converters that write directly to a slice without virtual method calls inside the conversion loop to work without an intermediate copy in the common case (i.e. with the default trait implementations) while not breaking compatibility with custom implementations of the traits. (And by giving access to the whole container object rather than just a slice, this allow the converter to tell the container to grow appropriately.)

…ase.

When `StringWriter` is a `String`, provide access to the `String`.
When `ByteWriter` is a `Vec<u8>`, provide access to the `Vec<u8>`.

This allows converters that write directly to a slice without
virtual method calls inside the conversion loop to work without
an intermediate copy in the common case (i.e. with the default
trait implementations) while not breaking compatibility with
custom implementations of the traits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant