Procházet zdrojové kódy

Some trivial changes to get rid of a few implicitly-unwrapped optionals.

Daniel Alm před 7 roky
rodič
revize
e4741df6cd
2 změnil soubory, kde provedl 5 přidání a 3 odebrání
  1. 3 1
      Sources/gRPC/ByteBuffer.swift
  2. 2 2
      Sources/gRPC/Server.swift

+ 3 - 1
Sources/gRPC/ByteBuffer.swift

@@ -21,7 +21,7 @@ import Foundation // for String.Encoding
 /// Representation of raw data that may be sent and received using gRPC
 public class ByteBuffer {
   /// Pointer to underlying C representation
-  internal var underlyingByteBuffer: UnsafeMutableRawPointer!
+  internal var underlyingByteBuffer: UnsafeMutableRawPointer
   
   /// Creates a ByteBuffer from an underlying C representation.
   /// The ByteBuffer takes ownership of the passed-in representation.
@@ -35,9 +35,11 @@ public class ByteBuffer {
   ///
   /// - Parameter data: the data to store in the buffer
   public init(data: Data) {
+    var underlyingByteBuffer: UnsafeMutableRawPointer?
     data.withUnsafeBytes { bytes in
       underlyingByteBuffer = cgrpc_byte_buffer_create_by_copying_data(bytes, data.count)
     }
+    self.underlyingByteBuffer = underlyingByteBuffer!
   }
   
   deinit {

+ 2 - 2
Sources/gRPC/Server.swift

@@ -28,13 +28,13 @@ public class Server {
   var completionQueue: CompletionQueue
   
   /// Active handlers
-  private var handlers: NSMutableSet!
+  private var handlers: NSMutableSet
   
   /// Mutex for synchronizing access to handlers
   private var handlersMutex: Mutex = Mutex()
   
   /// Optional callback when server stops serving
-  private var onCompletion: (() -> Void)!
+  private var onCompletion: (() -> Void)?
   
   /// Initializes a Server
   ///