zingolabs / zcashrpc

An async zcashd RPC client rust crate.
MIT License
2 stars 1 forks source link

represent numbers from JSON as rust_decimal::Decimals #36

Closed zancas closed 3 years ago

zancas commented 3 years ago

This change makes all values that are read from JSON, and are numbers to be "Decimals".

Decimals have explicit-and-fixed precision. Numbers written down in JSON, also have explicit and fixed precision.

Because of this, the correct representation for JSON numbers is a Decimal.

The change is:

dannasessha commented 3 years ago

Is there another way to achieve the function of the use statement?

If so, what are the pros and cons of using a use?

dannasessha commented 3 years ago

The approach seems well-reasoned and the changes look fine.

Running cargo test --all yields 3 passed tests.

test getinfo ... ok test getblockchaininfo ... ok test z_getnewaddress ... ok

AloeareV commented 3 years ago

Is there another way to achieve the function of the use statement?

If so, what are the pros and cons of using a use?

In most situations, use foo::Blar can be removed by explicitly pathing, i.e. replacing any calls to Blar with foo::Blar. However, in order to call a trait method, you need to bring the trait into scope by 'use'ing it. We like to do this by saying use Bandana as _ to make it clear the thing we are useing is being brought into scope, and not directly accessed.