diff --git a/ActiveLabel/ActiveType.swift b/ActiveLabel/ActiveType.swift index e339cb81..dc329544 100644 --- a/ActiveLabel/ActiveType.swift +++ b/ActiveLabel/ActiveType.swift @@ -13,7 +13,7 @@ enum ActiveElement { case hashtag(String) case url(original: String, trimmed: String) case custom(String) - + static func create(with activeType: ActiveType, text: String) -> ActiveElement { switch activeType { case .mention: return mention(text) @@ -29,7 +29,7 @@ public enum ActiveType { case hashtag case url case custom(pattern: String) - + var pattern: String { switch self { case .mention: return RegexParser.mentionPattern @@ -41,12 +41,12 @@ public enum ActiveType { } extension ActiveType: Hashable, Equatable { - public var hashValue: Int { + public func hash(into hasher: inout Hasher) { switch self { - case .mention: return -1 - case .hashtag: return -2 - case .url: return -3 - case .custom(let regex): return regex.hashValue + case .mention: hasher.combine(-1) + case .hashtag: hasher.combine(-2) + case .url: hasher.combine(-3) + case .custom(let regex): hasher.combine(regex) } } }