exchange.rs passes Currency by value and by reference #10
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?
Two functions in the same file take the same
Copytype two different ways:ExchangeRate::new(from: Currency, to: Currency, ...)— by value.Exchange::rate(&self, from: &Currency, to: &Currency)— by reference.Doc examples on adjacent lines show both spellings, so a reader has no rule to
carry from one call to the next.
The crate-wide convention is
&Currency(Money::from_major,MoneyBag::balance), which makesnewthe outlier — though taking references toa
Copytype is itself something the guidelines discourage, so the crate-widechoice is worth revisiting rather than propagating.
The same question applies to
set_rate(&mut self, rate: &ExchangeRate)andcross_with(&self, other: &Self).ExchangeRateisCopy, and the referenceforces every call site into
desk.set_rate(&ExchangeRate::new(...)?).Guideline: C-CALLER-CONTROL.