Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add impl Encode for [T], where T: Encode (#542)
* Add impl Encode for [T], where T: Encode Since Encode takes a reference, this allows us to encode &[T] directly using this implementation. The encoding scheme is the same as for Vec<T>. This also makes the implementation for &[u8] superfluous, since we get an implementation for [u8] by virtue of u8 implementing encode. This also gives us free implementations for &[u16], &[u32], etc. which is quite useful. Nonetheless, we keep the implementation for &[u8] around, because the implementation can directly write a large number of bytes, which can be more efficient than the generic implementation. * Remove redundant Encode implementations Since we've implemented Encode for [T], this makes the implementation for Box<[T]> redundant (since we have a blanket implementation for Box<T>), and ditto for &[T], which this change replaces by combining the implementations for [T] and &T. * Reinclude comment about Encode specialization for &[u8]
- Loading branch information