A currency pair cannot be named in a const #26
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#26
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?
Every currency is an associated constant —
Currency::USDand the rest aregenerated as
pub constbybuild.rs— so a caller can name one wherever aconstant is allowed. A pair of them cannot follow:
Pair::new(src/exchange/rate.rs:392),base, andquoteare plainfunctions, though nothing in any of them needs to run at runtime: the struct is
two
Copyfields, the constructor moves them into place, and the accessors readthem back. Marking all three
const fnlets a caller keep a static table of thepairs their system quotes, which is what anyone assembling a rate feed writes
first.
ExchangeRatecannot join them — its constructor compares aDecimalagainstzero, and that comparison is not a const operation — so this stops at
Pair.Additive; nothing breaks.