The Copy types take self by value and by reference #15
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?
The
Copytypes now take their parameters by value (#10), but theirreceivers are still split two ways, and
Parsershows both in one type:Parser::assume_currency(mut self, currency: Currency) -> Self— by value.Parser::parse(&self, text: &str) -> Result<Money, ParseMoneyError>— byreference.
Formatdivides the same way: every builder method takesmut self, whileMoney::format_with(&self, format: Format)reaches for one by reference.ExchangeRategoes further and spells the same type both ways inside a singlesignature:
Money::checked_add(&self, other: Money)reads the same way. Having justsettled the argument side, the receiver is what is left of the question #10
asked: a reader still has no rule to carry from one call to the next.
Everything on
Money,Currency,ExchangeRate,IsoNumericCode, andParser::parseis a candidate. One method cannot follow, and should stay as itis:
IsoAlphabeticCode::as_strhands back a&strborrowed from the code's ownbytes, so it needs a receiver that outlives the call.
Clippy has nothing to say here —
trivially_copy_pass_by_refleaves receiversalone, and a pedantic run is clean — so this is a design choice rather than a
lint to satisfy.
Breaking for anyone holding a
&Moneyand calling a method on it directly,though auto-deref covers most call sites unchanged.