Lokathor / tinyvec

Just, really the littlest Vec you could need. So smol.
https://docs.rs/tinyvec
Apache License 2.0
648 stars 49 forks source link

Add implementation of Borsh::(De)Serialize traits #153

Open totikom opened 3 years ago

totikom commented 3 years ago

The same way, as you have serde traits under serde feature, you can add borsh traits under borsh feature.

Lokathor commented 3 years ago

I would accept such a PR but am unfamiliar with the crate and am unlikely to do this myself.

totikom commented 3 years ago

Looks like Borsh is implemented for both [T; N] and &[T], so it is possible, that #[derive(BorshSerialize)] will be sufficient. I'll try it and, if it will be successful, send a PR.

Shnatsel commented 3 years ago

The implementation of BorshSerialize specifically should probably just coerce TinyVec to a slice and serialize that. Deserialization, on the other hand, is trickier.

Note that it's also possible to implement this in borsh crate rather than tinyvec, and it may make more sense to do so.