Streamline some Encodable impls.

Making them consistent with similar impls.
This commit is contained in:
Nicholas Nethercote 2023-10-06 10:10:16 +11:00
parent 2db1d59830
commit 1d71971973

View File

@ -307,8 +307,7 @@ impl<S: Encoder, T: Encodable<S>> Encodable<S> for [T] {
impl<S: Encoder, T: Encodable<S>> Encodable<S> for Vec<T> { impl<S: Encoder, T: Encodable<S>> Encodable<S> for Vec<T> {
fn encode(&self, s: &mut S) { fn encode(&self, s: &mut S) {
let slice: &[T] = self; self.as_slice().encode(s);
slice.encode(s);
} }
} }
@ -332,8 +331,7 @@ impl<D: Decoder, T: Decodable<D>, A: Allocator + Default> Decodable<D> for Vec<T
impl<S: Encoder, T: Encodable<S>, const N: usize> Encodable<S> for [T; N] { impl<S: Encoder, T: Encodable<S>, const N: usize> Encodable<S> for [T; N] {
fn encode(&self, s: &mut S) { fn encode(&self, s: &mut S) {
let slice: &[T] = self; self.as_slice().encode(s);
slice.encode(s);
} }
} }
@ -516,8 +514,7 @@ fn decode(d: &mut D) -> Box<T, A> {
impl<S: Encoder, A: Array<Item: Encodable<S>>> Encodable<S> for SmallVec<A> { impl<S: Encoder, A: Array<Item: Encodable<S>>> Encodable<S> for SmallVec<A> {
fn encode(&self, s: &mut S) { fn encode(&self, s: &mut S) {
let slice: &[A::Item] = self; self.as_slice().encode(s);
slice.encode(s);
} }
} }