Files
RxSwift/RxTests/RxSwiftTests/TestImplementations/Subscription.swift
Seivan Heidari 8c87a92326 Preprocessor, RxSwift & RxSwiftTests converted to Swift 2
7 Failed tests
6 related to assinging to _ doesn't retain.
1 related to Tracer
2015-07-21 22:46:16 +02:00

41 lines
1006 B
Swift

//
// Subscription.swift
// Rx
//
// Created by Krunoslav Zaher on 2/14/15.
// Copyright (c) 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation
struct Subscription : Equatable, Hashable, CustomStringConvertible {
let subscribe : Time
let unsubscribe : Time
init(_ subscribe: Time) {
self.subscribe = subscribe
self.unsubscribe = Int.max
}
init(_ subscribe: Time, _ unsubscribe: Time) {
self.subscribe = subscribe
self.unsubscribe = unsubscribe
}
var hashValue : Int {
get {
return subscribe.hashValue ^ unsubscribe.hashValue
}
}
var description : String {
get {
let infiniteText = "Infinity"
return "(\(subscribe) : \(unsubscribe != Time.max ? String(unsubscribe) : infiniteText))"
}
}
}
func == (lhs: Subscription, rhs: Subscription) -> Bool {
return lhs.subscribe == rhs.subscribe && lhs.unsubscribe == rhs.unsubscribe
}