Skip to content

Commit 2bfdd55

Browse files
authored
Rename generic type from B to Bound in PostgresRange (#367)
1 parent 62080bf commit 2bfdd55

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Sources/PostgresNIO/New/Data/Range+PostgresCodable.swift

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,16 @@ extension Int64: PostgresRangeArrayDecodable {}
6868
// MARK: PostgresRange
6969

7070
@usableFromInline
71-
struct PostgresRange<B> {
72-
@usableFromInline let lowerBound: B?
73-
@usableFromInline let upperBound: B?
71+
struct PostgresRange<Bound> {
72+
@usableFromInline let lowerBound: Bound?
73+
@usableFromInline let upperBound: Bound?
7474
@usableFromInline let isLowerBoundInclusive: Bool
7575
@usableFromInline let isUpperBoundInclusive: Bool
7676

7777
@inlinable
7878
init(
79-
lowerBound: B?,
80-
upperBound: B?,
79+
lowerBound: Bound?,
80+
upperBound: Bound?,
8181
isLowerBoundInclusive: Bool,
8282
isUpperBoundInclusive: Bool
8383
) {
@@ -96,7 +96,7 @@ struct PostgresRangeFlag {
9696
@usableFromInline static let isUpperBoundInclusive: UInt8 = 0x04
9797
}
9898

99-
extension PostgresRange: PostgresDecodable where B: PostgresRangeDecodable {
99+
extension PostgresRange: PostgresDecodable where Bound: PostgresRangeDecodable {
100100
@inlinable
101101
init<JSONDecoder: PostgresJSONDecoder>(
102102
from byteBuffer: inout ByteBuffer,
@@ -119,37 +119,37 @@ extension PostgresRange: PostgresDecodable where B: PostgresRangeDecodable {
119119

120120
let isEmpty: Bool = flags & PostgresRangeFlag.isEmpty != 0
121121
if isEmpty {
122-
self = PostgresRange<B>(
123-
lowerBound: B.valueForEmptyRange,
124-
upperBound: B.valueForEmptyRange,
122+
self = PostgresRange(
123+
lowerBound: Bound.valueForEmptyRange,
124+
upperBound: Bound.valueForEmptyRange,
125125
isLowerBoundInclusive: true,
126126
isUpperBoundInclusive: false
127127
)
128128
return
129129
}
130130

131131
guard let lowerBoundSize: Int32 = byteBuffer.readInteger(as: Int32.self),
132-
Int(lowerBoundSize) == MemoryLayout<B>.size,
132+
Int(lowerBoundSize) == MemoryLayout<Bound>.size,
133133
var lowerBoundBytes: ByteBuffer = byteBuffer.readSlice(length: Int(lowerBoundSize))
134134
else {
135135
throw PostgresDecodingError.Code.failure
136136
}
137137

138-
let lowerBound: B = try B(from: &lowerBoundBytes, type: boundType, format: format, context: context)
138+
let lowerBound = try Bound(from: &lowerBoundBytes, type: boundType, format: format, context: context)
139139

140140
guard let upperBoundSize = byteBuffer.readInteger(as: Int32.self),
141-
Int(upperBoundSize) == MemoryLayout<B>.size,
141+
Int(upperBoundSize) == MemoryLayout<Bound>.size,
142142
var upperBoundBytes: ByteBuffer = byteBuffer.readSlice(length: Int(upperBoundSize))
143143
else {
144144
throw PostgresDecodingError.Code.failure
145145
}
146146

147-
let upperBound: B = try B(from: &upperBoundBytes, type: boundType, format: format, context: context)
147+
let upperBound = try Bound(from: &upperBoundBytes, type: boundType, format: format, context: context)
148148

149149
let isLowerBoundInclusive: Bool = flags & PostgresRangeFlag.isLowerBoundInclusive != 0
150150
let isUpperBoundInclusive: Bool = flags & PostgresRangeFlag.isUpperBoundInclusive != 0
151151

152-
self = PostgresRange<B>(
152+
self = PostgresRange(
153153
lowerBound: lowerBound,
154154
upperBound: upperBound,
155155
isLowerBoundInclusive: isLowerBoundInclusive,
@@ -159,10 +159,10 @@ extension PostgresRange: PostgresDecodable where B: PostgresRangeDecodable {
159159
}
160160
}
161161

162-
extension PostgresRange: PostgresEncodable & PostgresNonThrowingEncodable where B: PostgresRangeEncodable {
162+
extension PostgresRange: PostgresEncodable & PostgresNonThrowingEncodable where Bound: PostgresRangeEncodable {
163163
@usableFromInline
164-
static var psqlType: PostgresDataType { return B.psqlRangeType }
165-
164+
static var psqlType: PostgresDataType { return Bound.psqlRangeType }
165+
166166
@usableFromInline
167167
static var psqlFormat: PostgresFormat { return .binary }
168168

@@ -177,31 +177,31 @@ extension PostgresRange: PostgresEncodable & PostgresNonThrowingEncodable where
177177
flags |= PostgresRangeFlag.isUpperBoundInclusive
178178
}
179179

180-
let boundMemorySize = Int32(MemoryLayout<B>.size)
180+
let boundMemorySize = Int32(MemoryLayout<Bound>.size)
181181

182182
byteBuffer.writeInteger(flags)
183-
if let lowerBound: B = self.lowerBound {
183+
if let lowerBound = self.lowerBound {
184184
byteBuffer.writeInteger(boundMemorySize)
185185
lowerBound.encode(into: &byteBuffer, context: context)
186186
}
187-
if let upperBound: B = self.upperBound {
187+
if let upperBound = self.upperBound {
188188
byteBuffer.writeInteger(boundMemorySize)
189189
upperBound.encode(into: &byteBuffer, context: context)
190190
}
191191
}
192192
}
193193

194-
extension PostgresRange where B: Comparable {
194+
extension PostgresRange where Bound: Comparable {
195195
@inlinable
196-
init(range: Range<B>) {
196+
init(range: Range<Bound>) {
197197
self.lowerBound = range.lowerBound
198198
self.upperBound = range.upperBound
199199
self.isLowerBoundInclusive = true
200200
self.isUpperBoundInclusive = false
201201
}
202202

203203
@inlinable
204-
init(closedRange: ClosedRange<B>) {
204+
init(closedRange: ClosedRange<Bound>) {
205205
self.lowerBound = closedRange.lowerBound
206206
self.upperBound = closedRange.upperBound
207207
self.isLowerBoundInclusive = true

0 commit comments

Comments
 (0)