Look up currencies by country code, and list a currency's countries #40
Labels
No labels
kind
bug
kind
enhancement
kind
refactor
workflow
needs-info
workflow
needs-triage
workflow
ready-for-agent
workflow
ready-for-human
workflow
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rosa/lucre#40
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
isodata.tsvalready carries aused_by_alpha2column, butbuild.rsneverreads it. Two additions would put it to work:
Currency::countries()— the countries a currency is used in.This is a proposal, not a decision. The trade-off in "Cost" below is the part
that needs a call.
Data bugs to fix first
These are worth fixing regardless of whether the API lands.
The
NADrow is column-shifted.isodata.tsv:105readsNAD 516 Namibian dollar N$ NA 2— the countryNAsits insubunit_symbol, andused_by_alpha2is empty. Nothing reads either fieldtoday, so Namibia would silently drop out the moment countries become API.
HRmaps only to a dead currency. Croatia appears underHRK, which isflagged
superseded(EUR), and is absent from theEURrow. A lookup forHRwould answer with the kuna.BGhas the same shape: Bulgaria is listedunder
BGNalone and is not in theEURrow.One country, several currencies
Nine countries use two currencies that are neither fund, special, nor
superseded:
BB,BM,BT,HT,IO,KH,LS,PA,SV. Panama usesboth
PABandUSD, and both answers are correct. So the reverse lookupreturns a slice; there is no singular
Currency::for_country()to offer.Coverage is otherwise good: 247 distinct country codes, 246 of them reachable
through a currency with no flags.
Proposed shape
A
CountryCode([u8; 2])newtype, validated as two capital ASCII letters,mirroring
IsoAlphabeticCode. Without it the API hands back bare&strin acrate whose every other code is a validated type.
Currency::countries(self) -> &'static [CountryCode]. One added field, a fatpointer;
Currencygrows by 16 bytes and staysCopy. Note that the derivedPartialEqandHashwould then walk the slice.Currency::used_in(code: CountryCode) -> &'static [Currency], generated inbuild.rsas one match arm per country, the way the existing code lookupsare. Document the order of the results so it is not accidental API.
Expose the
flagscolumn as a currency status (fund, special, superseded).It only feeds doc text today. A caller handed
[CUC, CUP]for Cuba has noway to drop the dead one, and country lookup is what makes that omission
bite.
Cost
The crate tracks one standard today. This makes it track two.
used_by_alpha2is not part of ISO 4217 — that standard names entities in English, not ISO 3166
alpha-2 — so the column is a hand-maintained join against a second standard with
its own churn. Eurozone accessions will rot it quietly, as
HRandBGalreadyshow.