<commit_before>//
//  Style.swift
//  ViewComponents
//
//  Created by Oleksii on 12/06/2017.
//  Copyright © 2017 WeAreReasonablePeople. All rights reserved.
//

import UIKit

public struct Style<View, Input, Key: RawRepresentable>: StyleType where Key.RawValue == Int {
    public let input: Input
    public let key: Key
    public let sideEffect: (View, Input) -> Void
    public let equality: (Input, Input) -> Bool
    public let hash: (Input) -> Int
    
    public init(_ input: Input, key: Key, sideEffect: @escaping (View, Input) -> Void, equality: @escaping (Input, Input) -> Bool, hash: @escaping (Input) -> Int) {
        self.input = input
        self.key = key
        self.sideEffect = sideEffect
        self.equality = equality
        self.hash = hash
    }
    
    public func sideEffect(on item: View) {
        sideEffect(item, input)
    }
    
    public static func == (lhs: Style<View, Input, Key>, rhs: Style<View, Input, Key>) -> Bool {
        return lhs.key == rhs.key && lhs.equality(lhs.input, rhs.input)
    }
    
    public var hashValue: Int {
        var hash = 5381
        hash = ((hash << 5) &+ hash) &+ key.rawValue.hashValue
        hash = ((hash << 5) &+ hash) &+ self.hash(input)
        return hash
    }
    
    public var toAnyStyle: AnyStyle<View> {
        return AnyStyle<View>(self)
    }
}

extension Style where Input: Hashable {
    public init(_ input: Input, key: Key, sideEffect: @escaping (View, Input) -> Void) {
        self.init(input, key: key, sideEffect: sideEffect, equality: { $0.0 == $0.1 }, hash: { $0.hashValue })
    }
}

extension Style where Input: Optionable, Input.WrappedType: Hashable {
    public init(_ input: Input, key: Key, sideEffect: @escaping (View, Input) -> Void) {
        self.init(input, key: key, sideEffect: sideEffect, equality: { $0.value == $1.value }, hash: { $0.value?.hashValue ?? 0 })
    }
}

extension Style: CustomStringConvertible {
    public var description: String {
        return "\(key): \(input)"
    }
}

extension Style where Input: Optionable {
    public var description: String {
        return "\(key): \(input._description)"
    }
}
<commit_msg>Remove redundant method<commit_after>//
//  Style.swift
//  ViewComponents
//
//  Created by Oleksii on 12/06/2017.
//  Copyright © 2017 WeAreReasonablePeople. All rights reserved.
//

import UIKit

public struct Style<View, Input, Key: RawRepresentable>: StyleType where Key.RawValue == Int {
    public let input: Input
    public let key: Key
    public let sideEffect: (View, Input) -> Void
    public let equality: (Input, Input) -> Bool
    public let hash: (Input) -> Int
    
    public init(_ input: Input, key: Key, sideEffect: @escaping (View, Input) -> Void, equality: @escaping (Input, Input) -> Bool, hash: @escaping (Input) -> Int) {
        self.input = input
        self.key = key
        self.sideEffect = sideEffect
        self.equality = equality
        self.hash = hash
    }
    
    public func sideEffect(on item: View) {
        sideEffect(item, input)
    }
    
    public static func == (lhs: Style<View, Input, Key>, rhs: Style<View, Input, Key>) -> Bool {
        return lhs.key == rhs.key && lhs.equality(lhs.input, rhs.input)
    }
    
    public var hashValue: Int {
        var hash = 5381
        hash = ((hash << 5) &+ hash) &+ key.rawValue.hashValue
        hash = ((hash << 5) &+ hash) &+ self.hash(input)
        return hash
    }
    
    public var toAnyStyle: AnyStyle<View> {
        return AnyStyle<View>(self)
    }
}

extension Style where Input: Hashable {
    public init(_ input: Input, key: Key, sideEffect: @escaping (View, Input) -> Void) {
        self.init(input, key: key, sideEffect: sideEffect, equality: { $0.0 == $0.1 }, hash: { $0.hashValue })
    }
}

extension Style where Input: Optionable, Input.WrappedType: Hashable {
    public init(_ input: Input, key: Key, sideEffect: @escaping (View, Input) -> Void) {
        self.init(input, key: key, sideEffect: sideEffect, equality: { $0.value == $1.value }, hash: { $0.value?.hashValue ?? 0 })
    }
}

extension Style: CustomStringConvertible {
    public var description: String {
        return "\(key): \(input)"
    }
}

{'fraction_non_alphanumeric': 0.13561741613133477, 'fraction_numerical': 0.01284796573875803, 'mean_word_length': 2.6461405030355594, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 31, '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': '7628163', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1307, 'n_words': 406}