From f5e16d3f0202bd9dee433f4f7cd7faa7aa2888ca Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Thu, 11 Jul 2024 15:16:05 -0700 Subject: [PATCH] fix indentation --- Sources/Future/RawSpan.swift | 162 +++++++++++++++++------------------ 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/Sources/Future/RawSpan.swift b/Sources/Future/RawSpan.swift index 9294450d..2e9eee9f 100644 --- a/Sources/Future/RawSpan.swift +++ b/Sources/Future/RawSpan.swift @@ -536,100 +536,100 @@ public struct OutOfBoundsError: Error { } } - extension RawSpan { +extension RawSpan { #if false // rdar://130971168 - /// Parse an instance of `T`, advancing `position`. - @inlinable - public func parse( - _ position: inout Int, as t: T.Type = T.self - ) throws(OutOfBoundsError) -> T { - let length = MemoryLayout.size - guard position >= 0 else { - throw OutOfBoundsError(expected: length, has: 0) - } - let end = position &+ length - guard end <= length else { - throw OutOfBoundsError(expected: length, has: byteCount&-position) - } - return unsafeLoadUnaligned(fromUncheckedByteOffset: position, as: T.self) - } + /// Parse an instance of `T`, advancing `position`. + @inlinable + public func parse( + _ position: inout Int, as t: T.Type = T.self + ) throws(OutOfBoundsError) -> T { + let length = MemoryLayout.size + guard position >= 0 else { + throw OutOfBoundsError(expected: length, has: 0) + } + let end = position &+ length + guard end <= length else { + throw OutOfBoundsError(expected: length, has: byteCount&-position) + } + return unsafeLoadUnaligned(fromUncheckedByteOffset: position, as: T.self) + } #endif - /// Parse `numBytes` of data, advancing `position`. - @inlinable - public func parse( - _ position: inout Int, numBytes: some FixedWidthInteger - ) throws (OutOfBoundsError) -> Self { - let length = Int(numBytes) - guard position >= 0 else { - throw OutOfBoundsError(expected: length, has: 0) - } - let end = position &+ length - guard end <= length else { - throw OutOfBoundsError(expected: length, has: byteCount&-position) - } - return extracting(position.. Self { + let length = Int(numBytes) + guard position >= 0 else { + throw OutOfBoundsError(expected: length, has: 0) + } + let end = position &+ length + guard end <= length else { + throw OutOfBoundsError(expected: length, has: byteCount&-position) + } + return extracting(position.. + /// The range within which we parse + public let parseRange: Range - /// The current parsing position - public var position: Int + /// The current parsing position + public var position: Int - @inlinable - public init(_ base: RawSpan, in range: Range) { - base.assertValidity(range) - position = 0 - self.base = base - parseRange = range - } + @inlinable + public init(_ base: RawSpan, in range: Range) { + base.assertValidity(range) + position = 0 + self.base = base + parseRange = range + } - @inlinable - public init(_ base: RawSpan) { - position = 0 - self.base = base - parseRange = base._byteOffsets - } + @inlinable + public init(_ base: RawSpan) { + position = 0 + self.base = base + parseRange = base._byteOffsets + } #if false // rdar://130971168 - /// Parse an instance of `T` and advance - @inlinable - public mutating func parse( - _ t: T.Type = T.self - ) throws(OutOfBoundsError) -> T { - try base.parse(&position, as: T.self) - } + /// Parse an instance of `T` and advance + @inlinable + public mutating func parse( + _ t: T.Type = T.self + ) throws(OutOfBoundsError) -> T { + try base.parse(&position, as: T.self) + } - /// Parse `numBytes`and advance - @inlinable - public mutating func parse( - numBytes: some FixedWidthInteger - ) throws (OutOfBoundsError) -> RawSpan { - try base.parse(&position, numBytes: numBytes) - } + /// Parse `numBytes`and advance + @inlinable + public mutating func parse( + numBytes: some FixedWidthInteger + ) throws (OutOfBoundsError) -> RawSpan { + try base.parse(&position, numBytes: numBytes) + } #endif - /// The bytes that we've parsed so far - @inlinable - public var parsedBytes: RawSpan { base.extracting(.. Cursor { Cursor(self) } + @inlinable + public func makeCursor() -> Cursor { Cursor(self) } - @inlinable - public func makeCursor(in range: Range) -> Cursor { - Cursor(self, in: range) - } - } + @inlinable + public func makeCursor(in range: Range) -> Cursor { + Cursor(self, in: range) + } +}