func mapAllOrFail()

in Cyborg/VectorDrawableParser.swift [43:53]


    func mapAllOrFail<T>(_ function: (Element) -> Result<T>) -> Result<[T]> {
        var result = [T]()
        result.reserveCapacity(underestimatedCount)
        for element in self {
            switch function(element) {
            case .ok(let wrapped): result.append(wrapped)
            case .error(let error): return .error(error)
            }
        }
        return .ok(result)
    }