@@ -39,11 +39,11 @@ public struct BinaryDistinctString: Equatable, Hashable, Sendable, Comparable, C
39
39
public init ( _ str: String ) {
40
40
self . init ( str as NSString )
41
41
}
42
-
42
+
43
43
public init ( _ character: BinaryDistinctCharacter ) {
44
44
self . value = character. bytes
45
45
}
46
-
46
+
47
47
public init ( _ characters: [ BinaryDistinctCharacter ] ) {
48
48
var data : [ UInt16 ] = [ ]
49
49
for character in characters {
@@ -64,11 +64,11 @@ public struct BinaryDistinctString: Equatable, Hashable, Sendable, Comparable, C
64
64
public static func < ( lhs: BinaryDistinctString , rhs: BinaryDistinctString ) -> Bool {
65
65
return lhs. value. lexicographicallyPrecedes ( rhs. value)
66
66
}
67
-
67
+
68
68
public static func + ( lhs: BinaryDistinctString , rhs: BinaryDistinctString ) -> BinaryDistinctString {
69
69
return BinaryDistinctString ( lhs. value + rhs. value)
70
70
}
71
-
71
+
72
72
public func hasPrefix( _ prefix: BinaryDistinctString ) -> Bool {
73
73
guard prefix. value. count <= self . value. count else { return false }
74
74
return self . value. starts ( with: prefix. value)
@@ -78,11 +78,11 @@ public struct BinaryDistinctString: Equatable, Hashable, Sendable, Comparable, C
78
78
guard suffix. value. count <= self . value. count else { return false }
79
79
return self . value. suffix ( suffix. value. count) == suffix. value
80
80
}
81
-
81
+
82
82
public func lowercased( ) -> BinaryDistinctString {
83
83
. init( self . string. lowercased ( ) )
84
84
}
85
-
85
+
86
86
public func replacingOccurrences( of: Self , with: Self ) -> BinaryDistinctString {
87
87
return BinaryDistinctString ( self . string. replacingOccurrences ( of: of. string, with: with. string) )
88
88
}
@@ -101,11 +101,11 @@ extension BinaryDistinctString {
101
101
}
102
102
return newIndex
103
103
}
104
-
104
+
105
105
public func index( _ i: Index , offsetBy distance: Int , limitedBy limit: Index ) -> Index ? {
106
- let newIndex = i + distance
107
- return newIndex <= limit ? newIndex : nil
108
- }
106
+ let newIndex = i + distance
107
+ return newIndex <= limit ? newIndex : nil
108
+ }
109
109
}
110
110
111
111
extension BinaryDistinctString : Sequence {
@@ -165,7 +165,7 @@ extension Dictionary where Key == BinaryDistinctString {
165
165
public mutating func merge( _ other: [ BinaryDistinctString : Value ] , strategy: ( Value , Value ) -> Value = { _, new in new } ) {
166
166
self . merge ( other, uniquingKeysWith: strategy)
167
167
}
168
-
168
+
169
169
/// Merges a `[String: Value]` dictionary into this one
170
170
public mutating func merge( _ other: [ String : Value ] , strategy: ( Value , Value ) -> Value = { _, new in new } ) {
171
171
let converted = Dictionary ( uniqueKeysWithValues: other. map { ( BinaryDistinctString ( $0. key) , $0. value) } )
@@ -183,7 +183,7 @@ extension Dictionary where Key == BinaryDistinctString {
183
183
newDict. merge ( other, strategy: strategy)
184
184
return newDict
185
185
}
186
-
186
+
187
187
public func merging( _ other: [ BinaryDistinctString : Value ] , strategy: ( Value , Value ) -> Value = { _, new in new } ) -> Self {
188
188
var newDict = self
189
189
newDict. merge ( other, strategy: strategy)
@@ -222,7 +222,7 @@ public struct BinaryDistinctCharacter: Equatable, Hashable, CustomStringConverti
222
222
public init ( bytes: [ UInt16 ] ) {
223
223
self . bytes = bytes
224
224
}
225
-
225
+
226
226
/// Satisfies ``ExpressibleByStringLiteral`` protocol.
227
227
public init ( stringLiteral value: String ) {
228
228
self . init ( value)
0 commit comments