Operator forwarding is written out by hand, 366 lines of it #33
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#33
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
MoneyandMoneyBagbetween them spend around 366 lines forwarding operators:the same
fn add(self, rhs: &Money) -> Money { self + *rhs }and itspermutations, written out for every combination of owned and borrowed operand,
for
Add,Sub,AddAssign, andSubAssign.The crate already shows how to do this once.
impl_scalar_mul!generates elevenimpls and carries a
# Panicsnote through the expansion. Extend that approachto a macro covering the borrowed-operand triple and the assigning variants, and
use it for both types.
Behaviour does not change: the same operand combinations compile, and the same
panic messages come out.
Acceptance criteria
Add,Sub,AddAssign, andSubAssignMoneyandMoneyBaguse it# Panicsdocumentation still appears on the generated impls incargo docmise run cipassesBlocked by
None — can start immediately. Note that this touches the same regions of
lib.rsandbag.rsthat the module split and theMoneyBagcopying work alsotouch; whichever lands second will need to rebase.
I've decided I'd rather have these hand-written than make some nasty macro