Skip to content

Commit af224c0

Browse files
authored
[stdlib] Various minor documentation edits (#3614)
* [stdlib] Fix UTF8View example code * [stdlib] Update code sample for SE-0099 * [stdlib] Standardize operator naming * [stdlib] Minor edits to Error documentation
1 parent 6152c41 commit af224c0

File tree

7 files changed

+26
-25
lines changed

7 files changed

+26
-25
lines changed

stdlib/public/core/Arrays.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ if True:
229229
/// array's first and last elements. If the array is empty, these properties
230230
/// are `nil`.
231231
///
232-
/// if let firstElement = oddNumbers.first, lastElement = oddNumbers.last {
232+
/// if let firstElement = oddNumbers.first, let lastElement = oddNumbers.last {
233233
/// print(firstElement, lastElement, separator: ", ")
234234
/// }
235235
/// // Prints "1, 15"

stdlib/public/core/Comparable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
/// =====================================
4949
///
5050
/// Types with Comparable conformance implement the less-than operator (`<`)
51-
/// and the is-equal-to operator (`==`). These two operations impose a strict
51+
/// and the equal-to operator (`==`). These two operations impose a strict
5252
/// total order on the values of a type, in which exactly one of the following
5353
/// must be true for any two values `a` and `b`:
5454
///

stdlib/public/core/Equatable.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
/// A type that can be compared for value equality.
1818
///
1919
/// Types that conform to the `Equatable` protocol can be compared for equality
20-
/// using the is-equal-to operator (`==`) or inequality using the
21-
/// is-not-equal-to operator (`!=`). Most basic types in the Swift standard
22-
/// library conform to `Equatable`.
20+
/// using the equal-to operator (`==`) or inequality using the not-equal-to
21+
/// operator (`!=`). Most basic types in the Swift standard library conform to
22+
/// `Equatable`.
2323
///
2424
/// Some sequence and collection operations can be used more simply when the
2525
/// elements conform to `Equatable`. For example, to check whether an array
@@ -48,10 +48,10 @@
4848
/// `Comparable` protocols, which allow more uses of your custom type, such as
4949
/// constructing sets or sorting the elements of a collection.
5050
///
51-
/// To adopt the `Equatable` protocol, implement the "is equal to" operator
52-
/// (`==`). The standard library provides an implementation for the "is not
53-
/// equal to" operator (`!=`) for any `Equatable` type, which calls the custom
54-
/// `==` function and negates its result.
51+
/// To adopt the `Equatable` protocol, implement the equal-to operator (`==`).
52+
/// The standard library provides an implementation for the not-equal-to
53+
/// operator (`!=`) for any `Equatable` type, which calls the custom `==`
54+
/// function and negates its result.
5555
///
5656
/// As an example, consider a `StreetAddress` structure that holds the parts of
5757
/// a street address: a house or building number, the street name, and an
@@ -136,9 +136,9 @@
136136
/// return lhs.value == rhs.value
137137
/// }
138138
///
139-
/// The implementation of the `==` function returns the same value whether
140-
/// its two arguments are the same instance or are two different instances
141-
/// with the same integer stored in their `value` properties. For example:
139+
/// The implementation of the `==` function returns the same value whether its
140+
/// two arguments are the same instance or are two different instances with
141+
/// the same integer stored in their `value` properties. For example:
142142
///
143143
/// let a = IntegerRef(100)
144144
/// let b = IntegerRef(100)
@@ -147,7 +147,7 @@
147147
/// // Prints "true, true"
148148
///
149149
/// Class instance identity, on the other hand, is compared using the
150-
/// triple-equals "is identical to" operator (`===`). For example:
150+
/// triple-equals identical-to operator (`===`). For example:
151151
///
152152
/// let c = a
153153
/// print(a === c, b === c, separator: ", ")
@@ -169,7 +169,7 @@ public protocol Equatable {
169169
/// Inequality is the inverse of equality. For any values `a` and `b`, `a != b`
170170
/// implies that `a == b` is `false`.
171171
///
172-
/// This is the default implementation of the is-not-equal-to operator (`!=`)
172+
/// This is the default implementation of the not-equal-to operator (`!=`)
173173
/// for any type that conforms to `Equatable`.
174174
///
175175
/// - Parameters:

stdlib/public/core/ErrorType.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ import SwiftShims
1414
// TODO: API review
1515
/// A type representing an error value that can be thrown.
1616
///
17-
/// Any type that declares conformance to `Error` can be used to
18-
/// represent an error in Swift's error handling system. Because
19-
/// `Error` has no requirements of its own, you can declare
20-
/// conformance on any custom type you create.
17+
/// Any type that declares conformance to the `Error` protocol can be used to
18+
/// represent an error in Swift's error handling system. Because the `Error`
19+
/// protocol has no requirements of its own, you can declare conformance on
20+
/// any custom type you create.
2121
///
2222
/// Using Enumerations as Errors
2323
/// ============================
2424
///
2525
/// Swift's enumerations are well suited to represent simple errors. Create an
26-
/// enumeration that conforms to `Error` with a case for each possible
27-
/// error. If there are additional details about the error that could be
28-
/// helpful for recovery, use associated values to include that information.
26+
/// enumeration that conforms to the `Error` protocol with a case for each
27+
/// possible error. If there are additional details about the error that could
28+
/// be helpful for recovery, use associated values to include that
29+
/// information.
2930
///
3031
/// The following example shows an `IntParsingError` enumeration that captures
3132
/// two different kinds of errors that can occur when parsing an integer from

stdlib/public/core/Hashable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
/// To use your own custom type in a set or as the key type of a dictionary,
3838
/// add `Hashable` conformance to your type by providing a `hashValue`
3939
/// property. The `Hashable` protocol inherits from the `Equatable` protocol,
40-
/// so you must also add an is-equal-to operator (`==`) function for your
40+
/// so you must also add an equal-to operator (`==`) function for your
4141
/// custom type.
4242
///
4343
/// As an example, consider a `GridPoint` type that describes a location in a

stdlib/public/core/String.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import SwiftShims
6060
/// print(greeting)
6161
/// // Prints "Welcome!"
6262
///
63-
/// Comparing strings for equality using the is-equal-to operator (`==`) or a
63+
/// Comparing strings for equality using the equal-to operator (`==`) or a
6464
/// relational operator (like `<` and `>=`) is always performed using the
6565
/// Unicode canonical representation. This means that different
6666
/// representations of a string compare as being equal.

stdlib/public/core/StringUTF8.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ extension String {
154154
///
155155
/// print(strncmp(s1, s2, 14))
156156
/// // Prints "0"
157-
/// print(String(s1.utf8.prefix(14))
157+
/// print(String(s1.utf8.prefix(14)))
158158
/// // Prints "They call me '"
159159
///
160160
/// Extending the compared character count to 15 includes the differing
161161
/// characters, so a nonzero result is returned.
162162
///
163163
/// print(strncmp(s1, s2, 15))
164164
/// // Prints "-17"
165-
/// print(String(s1.utf8.prefix(14))
165+
/// print(String(s1.utf8.prefix(15)))
166166
/// // Prints "They call me 'B"
167167
public struct UTF8View
168168
: Collection,

0 commit comments

Comments
 (0)