<commit_before>//
//  TextInputFormat+Bind.swift
//  TextInputKit
//
//  Created by <NAME> on 24/11/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

public protocol TextInputFormatBindable {

    func bind<Value>(format: TextInputFormat<Value>) -> TextInputBinding<Value>

}

public extension TextInputFormat {

    func bind<TextInput: TextInputFormatBindable>(to textInput: TextInput) -> TextInputBinding<Value> {
        return textInput.bind(format: self)
    }

}<commit_msg>Document TextInputFormat+Bind extension.<commit_after>//
//  TextInputFormat+Bind.swift
//  TextInputKit
//
//  Created by <NAME> on 24/11/2016.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import Foundation

/// A class representing a text input component (e.g. UITextField) should implement the `TextInputFormatBindable` protocol
/// to be able to be bound to a text input format using the `TextInputFormat.bind(to:)` API.
public protocol TextInputFormatBindable {

    /// Binds the text input format to `self`.
    ///
    /// - Parameters:
    ///   - format: The text input format.
    /// - Returns: The created `TextInputBinding`.
    func bind<Value>(format: TextInputFormat<Value>) -> TextInputBinding<Value>

}

public extension TextInputFormat {

    /// Binds the text input format to a text field, which conforms to the `TextInputFormatBindable` protocol.
    ///
    /// - Note:
    ///   This method only delegates the work to the `TextInputFormatBindable` protocol implementation.
    ///
    /// - Parameters:
    ///   - textField: The text field conforming to the `TextInputFormatBindable` protocol.
    /// - Returns: The created `TextInputBinding`.
    func bind<TextField: TextInputFormatBindable>(to textField: TextField) -> TextInputBinding<Value> {
        return textField.bind(format: self)
    }

}
{'fraction_non_alphanumeric': 0.11592632719393282, 'fraction_numerical': 0.013001083423618635, 'mean_word_length': 3.1977272727272728, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '3752676', 'n_tokens_mistral': 547, 'n_tokens_neox': 516, 'n_words': 161}