varunsrin / rusty_money

Money library for Rust
MIT License
90 stars 33 forks source link

Would it be alright to store the reverse key in addition to the regular key in an exchange? #51

Open JavedNissar opened 3 years ago

JavedNissar commented 3 years ago

If you store a rate for USD -> GBP and then you query for the rate for GBP -> USD, you get a None value. This doesn't seem correct to me. Shouldn't the value returned be 1/(rate returned for USD -> GBP)?

varunsrin commented 3 years ago

yes, the exchange rate crate isn't very mature right now, thanks for pointing out these issues.

i noticed some PR's, will review them over the weekend.

i will probably drop a new release (4.0.1) on Monday with any changes that are ready.

JavedNissar commented 3 years ago

That sounds good, no rush 😄 . I actually probably should add some tests anyways.

DavidBM commented 3 years ago

We found that the rate for USD -> GBP is not the same as the rate for GBP -> USD in the real world exchanges (example: currencylayer.com).

If the crate wants to align with the currency exchanges in the market, it should return None as in the majority of cases you will want to store two different rates.