near / borsh-rs

Rust implementation of Binary Object Representation Serializer for Hashing
https://borsh.io/
Apache License 2.0
310 stars 67 forks source link

FromIterator & IntoIterator types #75

Closed alexreg closed 2 years ago

alexreg commented 2 years ago

I was just curious, is there any reason that Borsh does not have generic implementations of BorshSerialize and BorshDeserialize for all IntoIterator and FromIterator types respectively? Presumably specialisation would then allow overriding this.

matklad commented 2 years ago

That'll break at least canonicity. eg, today we have BinaryHeap: BorshSerialize+Deserialize, but that is actually a bug: https://github.com/near/borsh-rs/issues/63#issuecomment-1000425206.

But more generally, I think serde doesn't have such impls either, and that reason might be more fundamental.

alexreg commented 2 years ago

Yeah, that's sort of what I suspected. Thanks for explaining.