Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add impl Encode for [T], where T: Encode #542

Merged
merged 3 commits into from
Jun 5, 2022

Commits on Jun 5, 2022

  1. 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.
    cronokirby committed Jun 5, 2022
    Configuration menu
    Copy the full SHA
    4242e12 View commit details
    Browse the repository at this point in the history
  2. 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.
    cronokirby committed Jun 5, 2022
    Configuration menu
    Copy the full SHA
    bc89890 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5edb104 View commit details
    Browse the repository at this point in the history