Skip to content

Releases: RougeWare/Swift-Optional-Tools

1.2 • Typed throws for `.unwrappedOrThrow()`

11 Oct 16:00
b02158c
Compare
Choose a tag to compare

This package's version 1.0 in 2019 simply contained .unwrappedOrThrow() and nothing else. The idea was simple: you place this after an Optional value, and if that value is nil, then it throws whatever error you give it, otherwise it returns that value. Like !/.unsafelyUnwrapped, but safer by using error-handling instead of potentially crashing.

Back then, there was no way to specify the type being thrown, and protocol-types weren't boxed the same if passed to something just taking that protocol's base type.

Now in Swift 6, not only is a bare protocol base type implicitly any, you can specify the type of a throws!

This release both uses the strong-generics typesystem to specify the type at compiletime, and also uses that type in the throws of this function!

All previous functionality and contracts remain exactly the same with this release; it just compiles much nicer and lets you use typed-throws. Hurray!

1.1.3 - Operators for Optionals

21 Jun 07:23
e930ecc
Compare
Choose a tag to compare

Added three new operators:

  • -? - If both have values, performs left - right. Otherwise, returns nil
  • +? - If both have values, performs left + right. Otherwise, returns nil
  • =? - If the right has a value, performs left = right. Otherwise, does nothing

Patch Changes

  • 1.1.3
    • Added a dynamic library product whose name is a valid bundle identifier
    • Deprecated previous dynamic library product because its name caused problems when submitting to the App Store
  • 1.1.2
    • Added alternative dynamic library product
  • 1.1.1
    • Added dual licenses

1.0.0 - MVP

10 Dec 07:30
Compare
Choose a tag to compare

Just .unwrappedOrThrow() for now 👍🏼