-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework AnyCurrency and CurrencyProtocol implementations (#25)
Motivation: While working on linux CI (#7) and due to bug #17, many holes in the current implementation were found. These include issues with handling NaN representations, integer overflow, performance, and code reusability. The primary issue is that the default implementations for protocol requirements were not playing nicely with each other, especially while compiling with Swift 5.2. Modifications: - Change: `init(exactly)` to be `init<T: BinaryInteger)(minorUnits:)` to be more forgiving to the types, and to avoid confusion with `Numeric` initializers - Change: `init(_:)` to be `init?(amount:)` to properly handle NaN values as well as to avoid `init(floatLiteral:)` accidental usage due to SE-0213 - Change: Code documentation to be more thorough and clear - Change: `inverse` from a computed property to `negated()`, catching overflow - Change: Localization from string interpolation is now explicit with `\(localize: <value>)` as the new form, to avoid clashes with the default interpolation behavior and default parameters Result: Implementations should be less buggy, Currency should compile in Swift 5+, with happier developers using the library.
- Loading branch information
Showing
13 changed files
with
591 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.