Skip to content

Commit

Permalink
deprecate BSON.Document and BSON.List’s Equatable conformances, since…
Browse files Browse the repository at this point in the history
… we are going to change its semantics
  • Loading branch information
tayloraswift committed Jan 13, 2025
1 parent 1fcb5e0 commit 574acec
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Sources/BSONABI/Primitives/BSON.Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ extension BSON.Document
self.output.append(other.bytes)
}
}

@available(*, deprecated)
extension BSON.Document:Equatable
{
/// Performs an exact byte-wise comparison on two documents. Does not parse or validate the
Expand Down
2 changes: 2 additions & 0 deletions Sources/BSONABI/Primitives/BSON.List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ extension BSON.List
@inlinable public
var size:Int { 5 + self.bytes.count }
}

@available(*, deprecated)
extension BSON.List:Equatable
{
/// Performs an exact byte-wise comparison on two lists.
Expand Down
2 changes: 1 addition & 1 deletion Sources/BSONEncodingTests/EncodingTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension EncodingTest
{
static func validate(encoded:BSON.Document, literal:BSON.Document) throws
{
#expect(encoded == literal)
#expect(encoded.bytes == literal.bytes)

let encoded:[BSON.FieldDecoder<BSON.Key>] = try encoded.parseAll()
let literal:[BSON.FieldDecoder<BSON.Key>] = try literal.parseAll()
Expand Down
2 changes: 1 addition & 1 deletion Sources/BSONLiterals/BSON.AnyValue (ext).swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BSON
import BSONABI

extension BSON.AnyValue:ExpressibleByStringLiteral,
ExpressibleByArrayLiteral,
Expand Down
4 changes: 2 additions & 2 deletions Sources/BSONTests/Primitives.swift
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ extension ValidBSON
#expect(document.header == size)

#expect(expected ~~ document)
#expect(expected == document)
#expect(expected.bytes == document.bytes)

if let degenerate:String
{
Expand All @@ -633,7 +633,7 @@ extension ValidBSON
let canonicalized:BSON.Document = try document.canonicalized()

#expect(expected ~~ document)
#expect(expected == canonicalized)
#expect(expected.bytes == canonicalized.bytes)
}
}
}

0 comments on commit 574acec

Please sign in to comment.