Skip to content

Commit

Permalink
Use synthesized Equatable & Hashable
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsprint09 authored and heckj committed Dec 23, 2024
1 parent 9bb3b5f commit c03bdbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 129 deletions.
132 changes: 6 additions & 126 deletions AutomergeUniffi/automerge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ public func FfiConverterTypeSyncState_lower(_ value: SyncState) -> UnsafeMutable
}


public struct Change {
public struct Change: Equatable, Hashable {
public var actorId: ActorId
public var message: String?
public var deps: [ChangeHash]
Expand All @@ -1508,41 +1508,6 @@ public struct Change {
}



extension Change: Equatable, Hashable {
public static func ==(lhs: Change, rhs: Change) -> Bool {
if lhs.actorId != rhs.actorId {
return false
}
if lhs.message != rhs.message {
return false
}
if lhs.deps != rhs.deps {
return false
}
if lhs.timestamp != rhs.timestamp {
return false
}
if lhs.bytes != rhs.bytes {
return false
}
if lhs.hash != rhs.hash {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(actorId)
hasher.combine(message)
hasher.combine(deps)
hasher.combine(timestamp)
hasher.combine(bytes)
hasher.combine(hash)
}
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -1585,7 +1550,7 @@ public func FfiConverterTypeChange_lower(_ value: Change) -> RustBuffer {
}


public struct KeyValue {
public struct KeyValue: Equatable, Hashable {
public var key: String
public var value: Value

Expand All @@ -1598,25 +1563,6 @@ public struct KeyValue {
}



extension KeyValue: Equatable, Hashable {
public static func ==(lhs: KeyValue, rhs: KeyValue) -> Bool {
if lhs.key != rhs.key {
return false
}
if lhs.value != rhs.value {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(key)
hasher.combine(value)
}
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -1651,7 +1597,7 @@ public func FfiConverterTypeKeyValue_lower(_ value: KeyValue) -> RustBuffer {
}


public struct Mark {
public struct Mark: Equatable, Hashable {
public var start: UInt64
public var end: UInt64
public var name: String
Expand All @@ -1668,33 +1614,6 @@ public struct Mark {
}



extension Mark: Equatable, Hashable {
public static func ==(lhs: Mark, rhs: Mark) -> Bool {
if lhs.start != rhs.start {
return false
}
if lhs.end != rhs.end {
return false
}
if lhs.name != rhs.name {
return false
}
if lhs.value != rhs.value {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(start)
hasher.combine(end)
hasher.combine(name)
hasher.combine(value)
}
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -1733,7 +1652,7 @@ public func FfiConverterTypeMark_lower(_ value: Mark) -> RustBuffer {
}


public struct Patch {
public struct Patch: Equatable, Hashable {
public var path: [PathElement]
public var action: PatchAction

Expand All @@ -1745,26 +1664,6 @@ public struct Patch {
}
}



extension Patch: Equatable, Hashable {
public static func ==(lhs: Patch, rhs: Patch) -> Bool {
if lhs.path != rhs.path {
return false
}
if lhs.action != rhs.action {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(path)
hasher.combine(action)
}
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -1799,7 +1698,7 @@ public func FfiConverterTypePatch_lower(_ value: Patch) -> RustBuffer {
}


public struct PathElement {
public struct PathElement: Equatable, Hashable {
public var prop: Prop
public var obj: ObjId

Expand All @@ -1812,25 +1711,6 @@ public struct PathElement {
}



extension PathElement: Equatable, Hashable {
public static func ==(lhs: PathElement, rhs: PathElement) -> Bool {
if lhs.prop != rhs.prop {
return false
}
if lhs.obj != rhs.obj {
return false
}
return true
}

public func hash(into hasher: inout Hasher) {
hasher.combine(prop)
hasher.combine(obj)
}
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
Expand Down Expand Up @@ -3548,4 +3428,4 @@ private func uniffiEnsureInitialized() {
}
}

// swiftlint:enable all
// swiftlint:enable all
3 changes: 0 additions & 3 deletions Sources/Automerge/Codable/BindingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import Foundation

/// Binding errors
public enum BindingError: LocalizedError, Equatable {
public static func == (lhs: BindingError, rhs: BindingError) -> Bool {
lhs.errorDescription == rhs.errorDescription
}

/// The path provided was invalid to bind into the Automerge document.
case InvalidPath(String)
Expand Down

0 comments on commit c03bdbc

Please sign in to comment.