Skip to content

Commit

Permalink
#139 Add OptionSet extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 6, 2024
1 parent d632733 commit de7dfa9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Sources/BluetoothGAP/Extensions/OptionSet.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// OptionSet.swift
// Bluetooth
//
// Created by Alsey Coleman Miller on 11/5/24.
//

extension OptionSet {
@inline(never)
internal func buildDescription(
_ descriptions: [(Element, StaticString)]
) -> String {
var copy = self
var result = "["

for (option, name) in descriptions {
if _slowPath(copy.contains(option)) {
result += name.description
copy.remove(option)
if !copy.isEmpty { result += ", " }
}
}

if _slowPath(!copy.isEmpty) {
result += "\(Self.self)(rawValue: \(copy.rawValue))"
}
result += "]"
return result
}
}

0 comments on commit de7dfa9

Please sign in to comment.