Skip to content

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

Open
hsivonen wants to merge 1 commit intolifthrasiir:masterfrom
hsivonen:string-vec-access
Open

Provide access to the underlying container of writers in the common case#108
hsivonen wants to merge 1 commit intolifthrasiir:masterfrom
hsivonen:string-vec-access

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