diff --git a/Sources/Data.swift b/Sources/Data.swift index 4f09d04..693e7e4 100644 --- a/Sources/Data.swift +++ b/Sources/Data.swift @@ -34,7 +34,7 @@ extension Data: RangeReplaceableCollection, MutableCollection { } #if swift(>=3.0) - public init(_ elements: S) { + public init(_ elements: S) where S.Iterator.Element == Byte { self.init(Array(elements)) } #else @@ -44,7 +44,7 @@ extension Data: RangeReplaceableCollection, MutableCollection { #endif #if swift(>=3.0) - public mutating func replaceSubrange(_ subRange: Range, with newElements: C) { + public mutating func replaceSubrange(_ subRange: Range, with newElements: C) where C.Iterator.Element == Byte { self.bytes.replaceSubrange(subRange, with: newElements) } #else @@ -123,7 +123,7 @@ public func == (lhs: Data, rhs: Data) -> Bool { } #if swift(>=3.0) - public func += (lhs: inout Data, rhs: S) { + public func += (lhs: inout Data, rhs: S) where S.Iterator.Element == Byte { return lhs.bytes += rhs } #else @@ -174,7 +174,7 @@ extension String: DataConvertible { loop: while true { switch decoder.decode(&generator) { - case .scalarValue(let char): string.append(char) + case .scalarValue(let char): string.unicodeScalars.append(char) case .emptyInput: break loop case .error: throw StringError() }