paritytech / paritytech/parity-scale-codec

EncodeLike<Self> should be implemented for all Encode types

Open
#159 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
287
Forks
103
Avg merge
6d 13h
Merged PRs (30d)
1

Description

in this context:

fn foo<T: Encode>(t: T) {
    put<T, _>(t);
}

fn put<T, EncodeLikeT: EncodeLike<T>>(like_t: EncodeLikeT) {}

this doesn't work because T doesn't implement EncodeLike, only Encode.
A way to solve this would be to have the following traits:

pub trait Encode: EncodeImpl + EncodeLike {}
impl<S: EncodeImpl + EncodeLike> Encode for S {}

and rename Encode -> EncodeImpl

but this is a breaking change. Actually maybe we may be able to change it without breaking substrate by first releasing new minor of version of parity-common/primitive-types with EncodeLike impls

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Encode, EncodeImpl, and EncodeLike trait definitions and their implementations in this Rust crate. Review compatibility with parity-common/primitive-types and the existing test suite; done means a decided, non-breaking path for making Encode values usable where EncodeLike is required.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.