File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
- realm/SwiftLint@0.55.1
1
+ realm/SwiftLint@0.57.0
2
2
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ struct GenerateMatrices: ParsableCommand {
83
83
]
84
84
85
85
// I’m assuming the JSONSerialization output has no newlines
86
- let keyValue = try " matrix= \( String ( decoding : JSONSerialization . data ( withJSONObject: matrix) , as : UTF8 . self ) ) "
86
+ let keyValue = try " matrix= \( String ( data : JSONSerialization . data ( withJSONObject: matrix) , encoding : . utf8 ) ) "
87
87
fputs ( " \( keyValue) \n " , stderr)
88
88
print ( keyValue)
89
89
}
@@ -173,6 +173,6 @@ struct Lint: AsyncParsableCommand {
173
173
174
174
private func loadUTF8StringFromFile( at path: String ) async throws -> String {
175
175
let ( data, _) = try await URLSession . shared. data ( from: . init( filePath: path) )
176
- return String ( decoding : data, as : UTF8 . self )
176
+ return try String ( data : data, encoding : . utf8 )
177
177
}
178
178
}
Original file line number Diff line number Diff line change
1
+ import Foundation
2
+
3
+ extension String {
4
+ enum DecodingError : Swift . Error {
5
+ case decodingFailed
6
+ }
7
+
8
+ /// Like `init(data:encoding:)`, but indicates decoding failure by throwing an error instead of returning an optional.
9
+ init ( data: Data , encoding: String . Encoding ) throws {
10
+ guard let decoded = String ( data: data, encoding: encoding) else {
11
+ throw DecodingError . decodingFailed
12
+ }
13
+
14
+ self = decoded
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments