Skip to content

Commit 55c430a

Browse files
committed
Cleanup, formatting
1 parent cea63ee commit 55c430a

File tree

5 files changed

+29
-21
lines changed

5 files changed

+29
-21
lines changed

Sources/SwiftASCII/ASCIICharacter.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
import Foundation
88

9-
/// ASCII Character:
109
/// A type containing a `Character` instance that is guaranteed to conform to ASCII encoding.
11-
/// Offers a validating `exactly: Character` failable initializer and a `_ lossy: Character`
10+
/// Offers a validating `init?(exactly: Character)` failable initializer and a `init(_ lossy: Character)`
1211
/// conversion initializer.
13-
public struct ASCIICharacter: Hashable {
12+
nonisolated
13+
public struct ASCIICharacter {
1414
/// The ASCII character returned as a `Character`
1515
public let characterValue: Character
1616

@@ -166,17 +166,17 @@ extension ASCIICharacter: Equatable {
166166
}
167167
}
168168

169+
extension ASCIICharacter: Hashable { }
170+
169171
extension ASCIICharacter: Codable {
170172
public init(from decoder: Decoder) throws {
171173
let container = try decoder.singleValueContainer()
172174
let string = try container.decode(String.self)
173175
guard let newInstance = Self(exactly: string) else {
174-
throw DecodingError.dataCorrupted(
175-
.init(
176-
codingPath: container.codingPath,
177-
debugDescription: "Value was not valid ASCII character number."
178-
)
179-
)
176+
throw DecodingError.dataCorrupted(.init(
177+
codingPath: container.codingPath,
178+
debugDescription: "Encoded value was not a valid ASCII character number."
179+
))
180180
}
181181
self = newInstance
182182
}
@@ -190,6 +190,8 @@ extension ASCIICharacter: Codable {
190190

191191
extension ASCIICharacter: Sendable { }
192192

193+
// MARK: - Operators
194+
193195
extension ASCIICharacter {
194196
public static func + (lhs: ASCIICharacter, rhs: ASCIICharacter) -> ASCIIString {
195197
ASCIIString([lhs, rhs])
@@ -236,6 +238,8 @@ extension ASCIICharacter {
236238
}
237239
}
238240

241+
// MARK: - Sequence Methods
242+
239243
extension Sequence where Element == ASCIICharacter {
240244
/// Returns a new string by concatenating the elements of the sequence.
241245
@_disfavoredOverload

Sources/SwiftASCII/ASCIIString.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
import Foundation
88

9-
/// ASCII String:
109
/// A type containing a `String` instance that is guaranteed to conform to ASCII encoding.
11-
/// Offers a validating `exactly: String` failable initializer and a `_ lossy: String` conversion
12-
/// initializer.
13-
public struct ASCIIString: Hashable {
10+
/// Offers a validating `init?(exactly: String)` failable initializer and a `init(_ lossy: String)`
11+
/// conversion initializer.
12+
nonisolated
13+
public struct ASCIIString {
1414
/// The ASCII string returned as a `String`
1515
public let stringValue: String
1616

@@ -129,17 +129,17 @@ extension ASCIIString: Equatable {
129129
}
130130
}
131131

132+
extension ASCIIString: Hashable { }
133+
132134
extension ASCIIString: Codable {
133135
public init(from decoder: Decoder) throws {
134136
let container = try decoder.singleValueContainer()
135137
let stringValue = try container.decode(String.self)
136138
guard let newInstance = Self(exactly: stringValue) else {
137-
throw DecodingError.dataCorrupted(
138-
.init(
139-
codingPath: container.codingPath,
140-
debugDescription: "Encoded string is not a valid ASCII string."
141-
)
142-
)
139+
throw DecodingError.dataCorrupted(.init(
140+
codingPath: container.codingPath,
141+
debugDescription: "Encoded string was not a valid ASCII string."
142+
))
143143
}
144144
self = newInstance
145145
}
@@ -152,6 +152,8 @@ extension ASCIIString: Codable {
152152

153153
extension ASCIIString: Sendable { }
154154

155+
// MARK: - Operators
156+
155157
extension ASCIIString {
156158
public static func + (lhs: ASCIIString, rhs: ASCIIString) -> ASCIIString {
157159
ASCIIString([lhs, rhs])
@@ -175,6 +177,8 @@ extension ASCIIString {
175177
}
176178
}
177179

180+
// MARK: - Sequence Methods
181+
178182
extension Sequence where Element == ASCIIString {
179183
/// Returns a new string by concatenating the elements of the sequence.
180184
@_disfavoredOverload

Sources/SwiftASCII/CharacterSet.swift renamed to Sources/SwiftASCII/CharacterSet Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// CharacterSet.swift
2+
// CharacterSet Extensions.swift
33
// swift-ascii • https://github.com/orchetect/swift-ascii
44
// © 2021-2025 Steffan Andrews • Licensed under MIT License
55
//

Sources/SwiftASCII/String.swift renamed to Sources/SwiftASCII/String Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// String.swift
2+
// String Extensions.swift
33
// swift-ascii • https://github.com/orchetect/swift-ascii
44
// © 2021-2025 Steffan Andrews • Licensed under MIT License
55
//

0 commit comments

Comments
 (0)