Skip to content

Commit 49f094c

Browse files
committed
NIO 2 shim: discardable result + optional count
write(string:) return Int?, but that should never happen even in NIO1.
1 parent 0615b31 commit 49f094c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Sources/NIOIRC/IRCChannelHandler.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,17 @@ extension ByteBuffer {
304304
}
305305

306306
#if swift(>=5)
307+
// NIO 2
307308
#else
308309
fileprivate extension ByteBuffer {
309310
// NIO 2 API for NIO 1
310311

311-
@inline(__always)
312+
@inline(__always) @discardableResult
312313
mutating func writeString(_ string: String) -> Int {
313-
return self.write(string: string)
314+
return self.write(string: string) ?? -1337 // never fails
314315
}
315316

316-
@inline(__always)
317+
@inline(__always) @discardableResult
317318
mutating func writeInteger<T: FixedWidthInteger>(_ integer: T) -> Int {
318319
return self.write(integer: integer)
319320
}

0 commit comments

Comments
 (0)