Skip to content

Commit

Permalink
Synthesize Equatable and Hashable conformance for Tree.Entry
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrubin committed Apr 12, 2019
1 parent e1acee3 commit 12f7d83
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions SwiftGit2/Objects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public struct Tree: ObjectType {
public static let type = GIT_OBJ_TREE

/// An entry in a `Tree`.
public struct Entry {
public struct Entry: Hashable {
/// The entry's UNIX file attributes.
public let attributes: Int32

Expand Down Expand Up @@ -176,26 +176,12 @@ public struct Tree: ObjectType {
}
}

extension Tree.Entry: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(attributes)
hasher.combine(object)
hasher.combine(name)
}
}

extension Tree.Entry: CustomStringConvertible {
public var description: String {
return "\(attributes) \(object) \(name)"
}
}

public func == (lhs: Tree.Entry, rhs: Tree.Entry) -> Bool {
return lhs.attributes == rhs.attributes
&& lhs.object == rhs.object
&& lhs.name == rhs.name
}

extension Tree: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(oid)
Expand Down

0 comments on commit 12f7d83

Please sign in to comment.