I am using a macro hex!
that accepts only string literals.
I have a value returned from a function and stored in a variable. I cannot hard-code the values and call this function. So, how can I call the hex!
macro with a variable?
This is my working code:
let account: AccountId32 = hex_literal::hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"].into();
and this is the code where I am facing the error:
let account_id = "d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d";
let account: AccountId32 = hex_literal::hex!(&account_id).into();
The error is:
error: proc-macro derive panicked
--> src/examples/example_substratekitties.rs:49:32
|
49 | let account: AccountId32 = hex_literal::hex!(&account_id).into();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: message: expected one string literal
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
All the examples of the hex!
macro only demonstrate it with string literals.