Skip to content

Commit 7640e07

Browse files
committed
remove equatable conformance
1 parent 6a4b741 commit 7640e07

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Sources/Sharing/Internal/Reference.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ where Base: MutableReference, Mapper: _MapReferenceWritableMapper<Base.Value, Va
613613
}
614614
}
615615

616-
protocol _MapReferenceMapper<Base, Value>: Sendable, Equatable {
616+
protocol _MapReferenceMapper<Base, Value>: Sendable {
617617
associatedtype Base
618618
associatedtype Value
619619

@@ -622,7 +622,7 @@ protocol _MapReferenceMapper<Base, Value>: Sendable, Equatable {
622622
func description(baseDescription: String) -> String
623623
}
624624

625-
protocol _MapReferenceWritableMapper<Base, Value>: _MapReferenceMapper {
625+
protocol _MapReferenceWritableMapper<Base, Value>: _MapReferenceMapper, Equatable {
626626
func mutate<R>(_ base: inout Base, body: (inout Value) throws -> R) rethrows -> R
627627
}
628628

@@ -668,10 +668,6 @@ final class _MapReferenceBlockMapper<Base, Value>: _MapReferenceMapper {
668668
func description(baseDescription: String) -> String {
669669
".map(\(baseDescription), as: \(Value.self).self)"
670670
}
671-
672-
static func == (lhs: _MapReferenceBlockMapper, rhs: _MapReferenceBlockMapper) -> Bool {
673-
lhs === rhs
674-
}
675671
}
676672

677673
final class _OptionalReference<Base: Reference<Value?>, Value>:

Tests/SharingTests/EquatableTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,18 @@ struct EquatableTests {
3232
#expect(lhs == rhs)
3333
#expect($lhs == $rhs)
3434
}
35+
36+
@Test func map() {
37+
@Shared(value: 0) var base: Int
38+
@SharedReader var lhs: Int
39+
@SharedReader var rhs: Int
40+
_lhs = $base.map { $0 * 2 }
41+
_rhs = $base.map { $0 * 3 }
42+
#expect(lhs == rhs)
43+
#expect($lhs == $rhs)
44+
45+
$base.withLock { $0 += 1 }
46+
#expect(lhs != rhs)
47+
#expect($lhs != $rhs)
48+
}
3549
}

0 commit comments

Comments
 (0)