The ISO code errors report invalidity without the code #19
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#19
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?
#13 replaced the crate's bare unit-struct errors with
#[non_exhaustive]enumson the grounds that a unit struct "discards the detail its operation had in
hand."
ExchangeRateError::InvalidRate(src/exchange.rs:817) follows throughand carries the multiplier it turned away, printing it in the message. Two
errors got the enum but not the detail:
Both are single-variant and payload-free.
IsoAlphabeticCode::try_from("us")(
src/lib.rs:934) has the text in hand, discards it, and reports only thatsomething was invalid;
TryFrom<[u8; 3]>(src/lib.rs:908) andTryFrom<u32>(src/lib.rs:858) do the same with their inputs. A callerreading a column of codes cannot say which one was at fault without threading
the input alongside the error.
The crate already has the other precedent:
ParseMoneyError::UnknownCurrency(
src/parse.rs:324) keeps the offending text, and prints it.Give both variants the input they rejected. The alphabetic code arrives as
&strin one path and[u8; 3]in the other, so aStringfield is the formthat suits both — at the cost of
Copy, whichIsoAlphabeticCodeErrordoes notcurrently derive anyway. The numeric one is a
u32and staysCopy.The enum shape from #13 bought room for the detail; this is taking it.
Guideline: C-GOOD-ERR.