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

Return length during const decoding #120

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

Conversation

joncinque
Copy link
Contributor

Problem

The current API for const-decoding only returns the resulting array, which makes it impossible for a user to check that the input had the correct length. This is an important use-case for things like wallet addresses, where people often make typos by forgetting to paste a character.

Proposed changes

Since there's no onto() API available in const contexts, this PR introduces a breaking change by having into_array_const also return the length decoded. I couldn't come up with a way to eliminate the breaking change without also introducing a lot of copied code, since we can't call Result::map in a const context.

I apologize for coming back with another change so soon, but I only discovered the issue when playing around with the API more recently. Let me know what you think!

The current API for const-decoding only returns the resulting array,
which makes it impossible for a user to check that the input had the
correct length. This is an important use-case for things like wallet
addresses, where people often make typos by forgetting to paste a
character.

Since there's no `onto()` API available in const contexts, this PR
introduces a breaking change by having `into_array_const` also return
the length decoded. I couldn't come up with a way to eliminate the
breaking change without also introducing a lot of copied code, since we
can't call `Result::map` in a const context.

I apologize for coming back with another change so soon, but I only
discovered the issue when playing around with the API more recently. Let
me know what you think!
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.

1 participant