Skip to content

Commit

Permalink
add inline Cond encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
tayloraswift committed Oct 22, 2024
1 parent 0c9e85c commit 6bf24b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "ebb16d1d1fcda74fd2dc0e0602e51cefaf7e287a565c2fb97f3924259fec5629",
"originHash" : "f3f9fc391509642da9593d2b621fe1a85a1b66c4e7197e28b38bf613cc7baabf",
"pins" : [
{
"identity" : "swift-atomics",
Expand Down Expand Up @@ -42,17 +42,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "1b33db2dea6a64d5b619b9e888175133c6d7f410",
"version" : "2.73.0"
"revision" : "f7dc3f527576c398709b017584392fb58592e7f5",
"version" : "2.75.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "a9fa5efd86e7ce2e5c1b6de113262e58035ca251",
"version" : "2.27.1"
"revision" : "d7ceaf0e4d8001cd35cdc12e42cdd281e9e564e8",
"version" : "2.28.0"
}
},
{
Expand Down
18 changes: 18 additions & 0 deletions Sources/MongoBuiltins/Expressions/Mongo.ExpressionEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,26 @@ extension Mongo.ExpressionEncoder
enum Cond:String, Sendable
{
case cond = "$cond"

@frozen public
enum Clause:String, Sendable
{
case `if`
case then
case `else`
}
}

@inlinable public
subscript(key:Cond, yield:(inout Mongo.SetEncoder<Cond.Clause>) -> ()) -> Void
{
mutating get
{
yield(&self.bson[with: key][as: Mongo.SetEncoder<Cond.Clause>.self])
}
}

@available(*, deprecated, message: "Use subscript(_:_:) instead.")
@inlinable public
subscript<Predicate, Then, Else>(key:Cond) -> (if:Predicate?, then:Then?, else:Else?)
where Predicate:BSONEncodable,
Expand Down

0 comments on commit 6bf24b5

Please sign in to comment.