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

Remove expect() in token transfer's acknowledgement conversion #389

Open
plafer opened this issue Jan 30, 2023 · 0 comments
Open

Remove expect() in token transfer's acknowledgement conversion #389

plafer opened this issue Jan 30, 2023 · 0 comments
Labels
S: conversions Scope: related to conversion processes S: errors Scope: related to error handlings

Comments

@plafer
Copy link
Contributor

plafer commented Jan 30, 2023

I'm also not a fan of needing that comment. Note also that I added a test to check that this conversion doesn't return a non-empty vector.

The fix would look like:

impl From<TokenTransferAcknowledgement> for NonEmptyVec<u8> {
    // ...
}

impl From<TokenTransferAcknowledgement> for Acknowledgement {
    fn from(ack: TokenTransferAcknowledgement) -> Self {
        let v: NonEmptyVec<u8> = ack.into();

        // this can be an `into()` because the only possible error case
        // (empty vector) is not possible with `NonEmptyVec<u8>`
        v.into()
    }
}

Originally posted by @plafer in #377 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: conversions Scope: related to conversion processes S: errors Scope: related to error handlings
Projects
Status: 📥 To Do
Development

Successfully merging a pull request may close this issue.

2 participants