Closed eternaleye closed 5 years ago
Thanks for opening this. I agree. I have become much more skeptical of specialization since writing that. I removed that part in https://github.com/serde-rs/bytes/commit/cef654193e25d961471275eb3ad434963f3764c3.
Thanks!
The README has this line:
Serialization in Go has taken a similar tack, always serialising
[]uint8
as[]bytes
, but this has significant knock-on effects which can be quite painful.As an example, serializing
[]int8
(&[i8]
) to JSON results in an array of numbers, while[]uint8
(&[u8]
) results in a base64 blob (credit @edef1c for the example).Taking this choice away from the user, by having specialization rather than explicit wrapper types, may make it difficult to impossible to comply with schemas that originate somewhere other than the Rust project using Serde - in Go, the solution is an expensive promotion to 16-bit integers, which costs a copy.