<commit_before>
public final class Subscription {
    private var completion: Void -> Void = {}
    deinit {
        completion()
    }
}

public final class Event<T> {
    public typealias Handler = T -> Void
    private typealias Subscriber = (token: Subscription, handler: Handler)
    private var subscribers: [Subscriber] = []

    public func subscribe(handler: Handler) -> Subscription {
        let newToken = Subscription()
        subscribers.append((newToken, handler))
        newToken.completion = { [weak self] in
            guard let welf = self else { return }
            welf.subscribers = welf.subscribers.filter { token, _ in
                return token !== newToken
            }
        }
        return newToken
    }

    public func post(data: T) {
        subscribers.forEach { _, handler in handler(data) }
    }
}<commit_msg>warn unused to prevent deallocating subscription before time.<commit_after>
public final class Subscription {
    private var completion: Void -> Void = {}
    deinit {
        completion()
    }
}

public final class Event<T> {
    public typealias Handler = T -> Void
    private typealias Subscriber = (token: Subscription, handler: Handler)
    private var subscribers: [Subscriber] = []

    @warn_unused_result(message: "subscription must be retained to receive events")
    public func subscribe(handler: Handler) -> Subscription {
        let newToken = Subscription()
        subscribers.append((newToken, handler))
        newToken.completion = { [weak self] in
            guard let welf = self else { return }
            welf.subscribers = welf.subscribers.filter { token, _ in
                return token !== newToken
            }
        }
        return newToken
    }

    public func post(data: T) {
        subscribers.forEach { _, handler in handler(data) }
    }
}
{'fraction_non_alphanumeric': 0.09066232356134636, 'fraction_numerical': 0.0, 'mean_word_length': 2.381651376146789, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '6697946', 'n_tokens_mistral': 508, 'n_tokens_neox': 482, 'n_words': 153}