rusty_money icon indicating copy to clipboard operation
rusty_money copied to clipboard

Request: NaiveMoney

Open mehcode opened this issue 2 years ago • 3 comments

It would be a useful abstraction to allow an unknown-currency NaiveMoney type that works as follows:

let money: NaiveMoney = NaiveMoney::from_minor(10);
let money: Money<USD> = money.with_currency(&USD);
  • NaiveMoney can only be constructed and converted to a Money<C>

In the abstract, this would be for any data structure that needs to store N monetary values where the currency type is determined dynamically from some other source.

As a concrete use case, I'd like to use this to represent MONEY from Postgres in SQLx.

Thoughts?

mehcode avatar Sep 16 '21 18:09 mehcode

I think the decision to have the currency type be static was a mistake. There are so many use cases where you need to deal with data that has mixed currency types. I really cannot use this library for the exact same reason. I am parsing a stream of transactions that have transactions in different currencies.

petar-dambovaliev avatar Jan 22 '22 15:01 petar-dambovaliev

I think the decision to have the currency type be static was a mistake. There are so many use cases where you need to deal with data that has mixed currency types. I really cannot use this library for the exact same reason. I am parsing a stream of transactions that have transactions in different currencies.

agreed

I was hoping to use this library, but its not usable in any system that needs to deal with arbitrary money values - for example I have money amounts coming from protocol buffers that encode a currency code and a string value - there is no way to use this data with this library

cameronbraid avatar Mar 11 '23 04:03 cameronbraid

I was also hoping to use this library, but it seems to lack iso::DEM and due to macro usage iso cannot be added to at "our" compile time. It feels odd to have to fork it simply to add an iso.

Perhaps the real issue for my use, is that iso and arbitrary_currency_family do not have an enum wrapper to provide equivalence. As a result, I cannot return either an iso, or an arbitrary currency family during deserialization. If I come up with something, I'll share.

RonaldLaBelle-Deckers avatar Nov 09 '23 01:11 RonaldLaBelle-Deckers