Skip to content

Commit 29e832a

Browse files
authored
Replace 'R' with 'Result' (#2709)
Motivation: Single letter names are discouraged but are used in a handful of places in NIOFileSystem. Modifications: - Replace 'R' with 'ReturnType' where appropriate Result: Clearer APIs
1 parent 8c3135b commit 29e832a

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

Sources/NIOFileSystem/BufferedWriter.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ extension WritableFileHandleProtocol {
231231
/// buffer to the file system when it exceeds this capacity. Defaults to 512 KiB.
232232
/// - body: The closure that writes the contents to the buffer created in this method.
233233
/// - Returns: The result of the executed closure.
234-
public func withBufferedWriter<R>(
234+
public func withBufferedWriter<Result>(
235235
startingAtAbsoluteOffset initialOffset: Int64 = 0,
236236
capacity: ByteCount = .kibibytes(512),
237-
execute body: (inout BufferedWriter<Self>) async throws -> R
238-
) async throws -> R {
237+
execute body: (inout BufferedWriter<Self>) async throws -> Result
238+
) async throws -> Result {
239239
var bufferedWriter = self.bufferedWriter(startingAtAbsoluteOffset: initialOffset, capacity: capacity)
240240
return try await withUncancellableTearDown {
241241
return try await body(&bufferedWriter)

Sources/NIOFileSystem/FileHandleProtocol.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,11 @@ extension DirectoryFileHandleProtocol {
581581
/// automatically after the closure exits.
582582
/// - Important: The handle passed to `execute` must not escape the closure.
583583
/// - Returns: The result of the `execute` closure.
584-
public func withFileHandle<R>(
584+
public func withFileHandle<Result>(
585585
forReadingAt path: FilePath,
586586
options: OpenOptions.Read = OpenOptions.Read(),
587-
execute body: (_ read: ReadFileHandle) async throws -> R
588-
) async throws -> R {
587+
execute body: (_ read: ReadFileHandle) async throws -> Result
588+
) async throws -> Result {
589589
let handle = try await self.openFile(forReadingAt: path, options: options)
590590

591591
return try await withUncancellableTearDown {
@@ -612,11 +612,11 @@ extension DirectoryFileHandleProtocol {
612612
/// automatically after the closure exits.
613613
/// - Important: The handle passed to `execute` must not escape the closure.
614614
/// - Returns: The result of the `execute` closure.
615-
public func withFileHandle<R>(
615+
public func withFileHandle<Result>(
616616
forWritingAt path: FilePath,
617617
options: OpenOptions.Write = .newFile(replaceExisting: false),
618-
execute body: (_ write: WriteFileHandle) async throws -> R
619-
) async throws -> R {
618+
execute body: (_ write: WriteFileHandle) async throws -> Result
619+
) async throws -> Result {
620620
let handle = try await self.openFile(forWritingAt: path, options: options)
621621

622622
return try await withUncancellableTearDown {
@@ -647,11 +647,11 @@ extension DirectoryFileHandleProtocol {
647647
/// automatically after the closure exits.
648648
/// - Important: The handle passed to `execute` must not escape the closure.
649649
/// - Returns: The result of the `execute` closure.
650-
public func withFileHandle<R>(
650+
public func withFileHandle<Result>(
651651
forReadingAndWritingAt path: FilePath,
652652
options: OpenOptions.Write = .newFile(replaceExisting: false),
653-
execute body: (_ readWrite: ReadWriteFileHandle) async throws -> R
654-
) async throws -> R {
653+
execute body: (_ readWrite: ReadWriteFileHandle) async throws -> Result
654+
) async throws -> Result {
655655
let handle = try await self.openFile(forReadingAndWritingAt: path, options: options)
656656

657657
return try await withUncancellableTearDown {
@@ -673,11 +673,11 @@ extension DirectoryFileHandleProtocol {
673673
/// - body: A closure which provides access to the directory.
674674
/// - Important: The handle passed to `execute` must not escape the closure.
675675
/// - Returns: The result of the `execute` closure.
676-
public func withDirectoryHandle<R>(
676+
public func withDirectoryHandle<Result>(
677677
atPath path: FilePath,
678678
options: OpenOptions.Directory = OpenOptions.Directory(),
679-
execute body: (_ directory: Self) async throws -> R
680-
) async throws -> R {
679+
execute body: (_ directory: Self) async throws -> Result
680+
) async throws -> Result {
681681
let handle = try await self.openDirectory(atPath: path, options: options)
682682

683683
return try await withUncancellableTearDown {

Sources/NIOFileSystem/FileSystem.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,10 @@ extension FileSystemProtocol where Self == FileSystem {
700700

701701
/// Provides temporary scoped access to a ``FileSystem`` with the given number of threads.
702702
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
703-
public func withFileSystem<R>(
703+
public func withFileSystem<Result>(
704704
numberOfThreads: Int,
705-
_ body: (FileSystem) async throws -> R
706-
) async throws -> R {
705+
_ body: (FileSystem) async throws -> Result
706+
) async throws -> Result {
707707
let fileSystem = await FileSystem(numberOfThreads: numberOfThreads)
708708
return try await withUncancellableTearDown {
709709
try await body(fileSystem)

Sources/NIOFileSystem/FileSystemProtocol.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ extension FileSystemProtocol {
274274
/// automatically after the closure exits.
275275
/// - Important: The handle passed to `execute` must not escape the closure.
276276
/// - Returns: The result of the `execute` closure.
277-
public func withFileHandle<R>(
277+
public func withFileHandle<Result>(
278278
forReadingAt path: FilePath,
279279
options: OpenOptions.Read = OpenOptions.Read(),
280-
execute: (_ read: ReadFileHandle) async throws -> R
281-
) async throws -> R {
280+
execute: (_ read: ReadFileHandle) async throws -> Result
281+
) async throws -> Result {
282282
let handle = try await self.openFile(forReadingAt: path, options: options)
283283
return try await withUncancellableTearDown {
284284
return try await execute(handle)
@@ -301,11 +301,11 @@ extension FileSystemProtocol {
301301
/// automatically after the closure exits.
302302
/// - Important: The handle passed to `execute` must not escape the closure.
303303
/// - Returns: The result of the `execute` closure.
304-
public func withFileHandle<R>(
304+
public func withFileHandle<Result>(
305305
forWritingAt path: FilePath,
306306
options: OpenOptions.Write = .newFile(replaceExisting: false),
307-
execute: (_ write: WriteFileHandle) async throws -> R
308-
) async throws -> R {
307+
execute: (_ write: WriteFileHandle) async throws -> Result
308+
) async throws -> Result {
309309
let handle = try await self.openFile(forWritingAt: path, options: options)
310310
return try await withUncancellableTearDown {
311311
return try await execute(handle)
@@ -333,11 +333,11 @@ extension FileSystemProtocol {
333333
/// automatically after the closure exits.
334334
/// - Important: The handle passed to `execute` must not escape the closure.
335335
/// - Returns: The result of the `execute` closure.
336-
public func withFileHandle<R>(
336+
public func withFileHandle<Result>(
337337
forReadingAndWritingAt path: FilePath,
338338
options: OpenOptions.Write = .newFile(replaceExisting: false),
339-
execute: (_ readWrite: ReadWriteFileHandle) async throws -> R
340-
) async throws -> R {
339+
execute: (_ readWrite: ReadWriteFileHandle) async throws -> Result
340+
) async throws -> Result {
341341
let handle = try await self.openFile(forReadingAndWritingAt: path, options: options)
342342
return try await withUncancellableTearDown {
343343
return try await execute(handle)
@@ -354,11 +354,11 @@ extension FileSystemProtocol {
354354
/// - execute: A closure which provides access to the directory.
355355
/// - Important: The handle passed to `execute` must not escape the closure.
356356
/// - Returns: The result of the `execute` closure.
357-
public func withDirectoryHandle<R>(
357+
public func withDirectoryHandle<Result>(
358358
atPath path: FilePath,
359359
options: OpenOptions.Directory = OpenOptions.Directory(),
360-
execute: (_ directory: DirectoryFileHandle) async throws -> R
361-
) async throws -> R {
360+
execute: (_ directory: DirectoryFileHandle) async throws -> Result
361+
) async throws -> Result {
362362
let handle = try await self.openDirectory(atPath: path, options: options)
363363
return try await withUncancellableTearDown {
364364
return try await execute(handle)
@@ -490,11 +490,11 @@ extension FileSystemProtocol {
490490
/// - options: Options used to create the directory.
491491
/// - execute: A closure which provides access to the directory and its path.
492492
/// - Returns: The result of `execute`.
493-
public func withTemporaryDirectory<ReturnType>(
493+
public func withTemporaryDirectory<Result>(
494494
prefix: FilePath? = nil,
495495
options: OpenOptions.Directory = OpenOptions.Directory(),
496-
execute: (_ directory: DirectoryFileHandle, _ path: FilePath) async throws -> ReturnType
497-
) async throws -> ReturnType {
496+
execute: (_ directory: DirectoryFileHandle, _ path: FilePath) async throws -> Result
497+
) async throws -> Result {
498498
let template: FilePath
499499

500500
if let prefix = prefix {

0 commit comments

Comments
 (0)