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

Use marker trait StrictCodec to indicate strict one-to-one correspondance #252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sorpaas
Copy link
Member

@sorpaas sorpaas commented Feb 21, 2021

This is related to #251. I'd like to put this out for discussions first to see if we like this approach before writing tests and other stuff.

This introduces a marker trait StrictCodec (together with derive(Strict)). Any types implementing StrictCodec are supposed to have strict one-to-one correspondence. This avoids accidentally introducing those non-strict types when it matters -- for example, when we need to handle user inputs and want to have peace of mind that we can freely decode and encode stuff.

@shawntabrizi
Copy link
Member

Gav mentioned in Element chat that he would like to have strict enabled by default, and something like #[codec(permissive)] to give the current behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants