Skip to content

Commit

Permalink
Merge pull request #6 from adam-fowler/sendable
Browse files Browse the repository at this point in the history
Sendable conformance
  • Loading branch information
adam-fowler authored Feb 26, 2022
2 parents afc4fdb + 166c1a0 commit 4513d31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Sources/JMESPath/Ast.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public indirect enum Ast: Equatable {
}

/// Comparator used in comparison AST nodes
public enum Comparator: Equatable {
public enum Comparator: Equatable, JMESSendable {
case equal
case notEqual
case lessThan
Expand All @@ -61,3 +61,9 @@ public enum Comparator: Equatable {
}
}
}

#if compiler(>=5.6)
// have to force Sendable conformance as enum `.literal` uses `JMESVariable` which
// is not necessarily sendable but in the use here it is
extension Ast: @unchecked Sendable {}
#endif
2 changes: 1 addition & 1 deletion Sources/JMESPath/Expression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
/// JMES Expression
///
/// Holds a compiled JMES expression and allows you to search Json text or a type already in memory
public struct JMESExpression {
public struct JMESExpression: JMESSendable {
let ast: Ast

public static func compile(_ text: String) throws -> Self {
Expand Down
7 changes: 7 additions & 0 deletions Sources/JMESPath/Sendable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Sendable support

#if compiler(>=5.6)
public typealias JMESSendable = Sendable
#else
public typealias JMESSendable = Any
#endif

0 comments on commit 4513d31

Please sign in to comment.