How to implement Serialize and Deserialize
I would to use serde json serialization for BigUint type. How can one do that?
If I write
#[derive(Serialize, Deserialize)]
pub struct Account {
value: BigUint
}
Then I get the error
| ^^^^^^^^^^^^^^^ the trait serde::Deserialize<'_> is not implemented for num_bigint::BigUint
How can i do this implementation? Is there a standard implementation?
You need to enable the "serde" feature of num-bigint. See the cargo docs for general instructions about features:
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#choosing-features
Do you think it would make sense to have all features on by default? Someone who wants to disable a feature probably knows what they're doing (at least more than average). It feels beginner-unfriendly as-is.
No, I'd rather not add to the build time by default. But we could probably do a better job of documenting the available features and how to use them (plus their associated minimum rustc).