Skip to content

Commit

Permalink
Update ActiveType.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
maziyarpanahi committed Apr 11, 2019
1 parent af93c76 commit cfcd992
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ActiveLabel/ActiveType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit cfcd992

Please sign in to comment.