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

Implement TryFrom<&Error> for ScVal #846

Merged
merged 2 commits into from Jun 14, 2023
Merged

Conversation

brson
Copy link
Contributor

@brson brson commented Jun 10, 2023

What

impl TryFrom<&Error> for ScVal

Why

Error cannot be stored in #[contracttype]s.

This impl is required for types to be stored in #[contracttype]. Without it the compiler produces errors like

error[E0277]: the trait bound `stellar_xdr::ScVal: From<&soroban_env_host::Error>` is not satisfied
    --> soroban-sdk/src/arbitrary.rs:1027:9
     |
1027 |         #[contracttype]
     |         ^^^^^^^^^^^^^^^ the trait `From<&soroban_env_host::Error>` is not implemented for `stellar_xdr::
ScVal`
     |
     = note: required for `&soroban_env_host::Error` to implement `Into<stellar_xdr::ScVal>`
     = note: required for `stellar_xdr::ScVal` to implement `TryFrom<&soroban_env_host::Error>`
     = note: required for `&soroban_env_host::Error` to implement `TryInto<stellar_xdr::ScVal>`
     = note: this error originates in the attribute macro `contracttype` (in Nightly builds, run with -Z macro-
backtrace for more info)
help: consider dereferencing here
     |
1027 |         (*#[contracttype])
     |         ++               +

For more information about this error, try `rustc --explain E0277`.
error: could not compile `soroban-sdk` (lib test) due to previous error
warning: build failed, waiting for other jobs to finish...

Known limitations

na

@leighmcculloch leighmcculloch enabled auto-merge (squash) June 14, 2023 03:12
@leighmcculloch leighmcculloch merged commit c2a5f1c into stellar:main Jun 14, 2023
8 checks passed
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.

None yet

2 participants