Skip to content

Commit

Permalink
Support: allow nil for HSTRING in String construction
Browse files Browse the repository at this point in the history
`HSTRING?` is the proper parameter type as the value `nil` is equivalent
to the empty string.
  • Loading branch information
compnerd committed Apr 3, 2021
1 parent fc1366b commit e4ebafb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/WinRT/Support/Swift+Extensions.swift
Expand Up @@ -4,7 +4,7 @@
import CWinRT

extension String {
internal init(from hString: HSTRING) {
internal init(from hString: HSTRING?) {
var length: UINT32 = 0
let pwszBuffer: PCWSTR = WindowsGetStringRawBuffer(hString, &length)
self.init(decoding: UnsafeBufferPointer(start: pwszBuffer, count: Int(length)), as: UTF16.self)
Expand Down

0 comments on commit e4ebafb

Please sign in to comment.