A MoneyBag copies itself to answer questions about itself #32
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#32
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?
What to build
MoneyBag::format_withsays nothing is allocated until the result is displayed.It clones the whole bag when it is called. The
use<>in its return type is whatforces the copy; borrowing instead makes the sentence true.
The same copy happens three more times.
covers,checked_add, andchecked_subtakeimpl Into<MoneyBag>and immediately convert, so passing aborrowed bag deep-copies it just to read its balances.
From<&MoneyBag> for MoneyBagexists only to satisfy that bound.Replace the bound with a sealed private trait that hands back an iterator of
balances, implemented for
Money,&Money,MoneyBag, and&MoneyBag. Thethree methods keep the argument types they accept today and stop copying.
From<&MoneyBag> for MoneyBaggoes away.Acceptance criteria
format_withborrows the bag, and its documentation matches what it doescovers,checked_add, andchecked_subread a borrowed bag without copying itMoney, owned and borrowedMoneyBag— still work at every call siteFrom<&MoneyBag> for MoneyBagis gonemise run cipassesBlocked by
None — can start immediately.