<commit_before>//
//  AsyncRequestState.swift
//  SwiftUtilities
//
//  Created by <NAME> on 8/21/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

public enum AsyncRequestState<S, F> {
    
    case none
    case waiting
    case success(S)
    case failure(F)
    
    public init(result: Result<S, F>) {
        switch result {
        case let .success(s):
            self = .success(s)
        case let .failure(f):
            self = .failure(f)
        }
    }
    
    public func getSuccess() -> S? {
        if case let .success(s) = self {
            return s
        }
        
        return nil
    }
    
    public func getFailure() -> F? {
        if case let .failure(f) = self {
            return f
        }
        
        return nil
    }
    
    public func toResult() -> Result<S, F>? {
        switch self {
        case .none, .waiting:
            return nil
        case let .success(s):
            return .success(s)
        case let .failure(f):
            return .failure(f)
        }
    }
    
    func map<S2>(_ transform: (S) -> S2) -> AsyncRequestState<S2, F> {
        switch self {
        case .none:
            return .none
        case .waiting:
            return .waiting
        case let .success(s):
            return .success(transform(s))
        case let .failure(f):
            return .failure(f)
        }
    }
    
}

public func == <S: Equatable, F: Equatable>(lhs: AsyncRequestState<S, F>, rhs: AsyncRequestState<S, F>) -> Bool {
    switch (lhs, rhs) {
    case (.none, .none), (.waiting, .waiting):
        return true
    case let (.success(left), .success(right)):
        return left == right
    case let (.failure(left), .failure(right)):
        return left == right
    default:
        return false
    }
}<commit_msg>Fix AsyncRequestState map function protection level.<commit_after>//
//  AsyncRequestState.swift
//  SwiftUtilities
//
//  Created by <NAME> on 8/21/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

public enum AsyncRequestState<S, F> {
    
    case none
    case waiting
    case success(S)
    case failure(F)
    
    public init(result: Result<S, F>) {
        switch result {
        case let .success(s):
            self = .success(s)
        case let .failure(f):
            self = .failure(f)
        }
    }
    
    public func getSuccess() -> S? {
        if case let .success(s) = self {
            return s
        }
        
        return nil
    }
    
    public func getFailure() -> F? {
        if case let .failure(f) = self {
            return f
        }
        
        return nil
    }
    
    public func toResult() -> Result<S, F>? {
        switch self {
        case .none, .waiting:
            return nil
        case let .success(s):
            return .success(s)
        case let .failure(f):
            return .failure(f)
        }
    }
    
    public func map<S2>(_ transform: (S) -> S2) -> AsyncRequestState<S2, F> {
        switch self {
        case .none:
            return .none
        case .waiting:
            return .waiting
        case let .success(s):
            return .success(transform(s))
        case let .failure(f):
            return .failure(f)
        }
    }
    
}

public func == <S: Equatable, F: Equatable>(lhs: AsyncRequestState<S, F>, rhs: AsyncRequestState<S, F>) -> Bool {
    switch (lhs, rhs) {
    case (.none, .none), (.waiting, .waiting):
        return true
    case let (.success(left), .success(right)):
        return left == right
    case let (.failure(left), .failure(right)):
        return left == right
    default:
        return false
    }
}
{'fraction_non_alphanumeric': 0.12260010970927043, 'fraction_numerical': 0.006582556226001097, 'mean_word_length': 1.497945205479452, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5997500', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1099, 'n_words': 320}