You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firstly thanks for all the great work you have put in this package. I like the simple style for dealing with money units.
I have a suggestion for the organization of the Currency structs for the myriad possible currency systems. Currently each currency set has it's own module, i.e. the Currency structs are disjoint. This raises problems when one tries to use Currencies from different currency sets together. The issue here is that type elision will not always work for implementers of FormattableCurrency especially in case of function return values - consider a function returning an object parameterized by <T: FormattableCurrency, S: FormattableCurrency>: if the specific implementing types of T and S are not known at the point where the function is invoked then the compiler will complain about it. The context for me is when trying to read a file of currency trades (not all iso currencies).
So my suggestion would be to have define currency set generate value consts of a unique Currency struct. If data fields are somewhat different we could also define a map from the unique currency struct to field names to the appropriate names for that specific currency set. Currency sets could then be held in a static CurrencySets struct mapping currency set name to an array of currency constants.
I realize this is not so easy but that's a kind of organization that seems more versatile from standpoint. I'd be happy to engage in a discussion about this but also happy to just hear your thoughts about this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi crate maintainers,
Firstly thanks for all the great work you have put in this package. I like the simple style for dealing with money units.
I have a suggestion for the organization of the Currency structs for the myriad possible currency systems. Currently each currency set has it's own module, i.e. the Currency structs are disjoint. This raises problems when one tries to use Currencies from different currency sets together. The issue here is that type elision will not always work for implementers of
FormattableCurrency
especially in case of function return values - consider a function returning an object parameterized by<T: FormattableCurrency, S: FormattableCurrency>
: if the specific implementing types of T and S are not known at the point where the function is invoked then the compiler will complain about it. The context for me is when trying to read a file of currency trades (not all iso currencies).So my suggestion would be to have define currency set generate value consts of a unique Currency struct. If data fields are somewhat different we could also define a map from the unique currency struct to field names to the appropriate names for that specific currency set. Currency sets could then be held in a static CurrencySets struct mapping currency set name to an array of currency constants.
I realize this is not so easy but that's a kind of organization that seems more versatile from standpoint. I'd be happy to engage in a discussion about this but also happy to just hear your thoughts about this.
Thanks,
Mphizi
Beta Was this translation helpful? Give feedback.
All reactions