Swiftpack.co -  christopherweems/Resultto as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
christopherweems/Resultto
A collection of handy result builders
.package(url: "https://github.com/christopherweems/Resultto.git", from: "v0.1.1")

Resultto

A collection of handy result builders.

Requires Swift 5.4+

AllNil

Returns true if all elements are nil. Elements are not required to be homogenous.

struct Element {
    var title: String?
    var description: String?
    var child: Self?
    
    @AllNil var isEmpty: Bool {
        title
        description
        child
        
    }
    
}

SingleResult

Returns a single element. Useful to avoid typing a few return keywords.

extension Bool {
    @SingleResult var enEspanol: Bool {
        switch self {
            case true: "Sí"
            case false: "No""
        }
    }
    
}

UUIDResult

Convienence formatter for specifying UUID properties

protocol UUIDIdentifiable: Identifiable where ID == UUID {
    @UUIDResult var id: UUID { get }
    
}

struct Element: UUIDIdentifiable {
    var id: UUID {
        (194, 210, 39, 207, 170, 13, 68, 151, 190, 189, 41, 237, 240, 95, 174, 248)
    }
    
}

Count

Total of true boolean values

struct FooBar {
    var foo: Int?
    var bar: Bool?
    
    @Count var nonOptionalCount: Int {
        foo != nil
        bar != nil
        
    }
    
}

GitHub

link
Stars: 0
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Add `Count` Result Builder
21 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API