Skip to content

Commit 1c5c111

Browse files
authored
Merge pull request swiftlang#36709 from amartini51/main
Doc comment corrections
2 parents f989c17 + 4b3064e commit 1c5c111

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

stdlib/public/Darwin/Foundation/NSStringAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ extension StringProtocol where Index == String.Index {
16691669
// forward trivially to rangeOfString.
16701670

16711671
/// Returns `true` if `other` is non-empty and contained within `self` by
1672-
/// case-sensitive, non-literal search. Otherwise, returns `false`.
1672+
/// case-sensitive, non-literal search; otherwise, returns `false`.
16731673
///
16741674
/// Equivalent to `self.range(of: other) != nil`
16751675
public func contains<T : StringProtocol>(_ other: T) -> Bool {

stdlib/public/core/Dictionary.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,8 @@ extension Dictionary: ExpressibleByDictionaryLiteral {
831831
}
832832

833833
extension Dictionary {
834-
/// Accesses the value with the given key. If the dictionary doesn't contain
835-
/// the given key, accesses the provided default value as if the key and
836-
/// default value existed in the dictionary.
834+
/// Accesses the value with the given key, falling back to the given default
835+
/// value if the key isn't found.
837836
///
838837
/// Use this subscript when you want either the value for a particular key
839838
/// or, when that key is not present in the dictionary, a default value. This
@@ -866,7 +865,7 @@ extension Dictionary {
866865
/// }
867866
/// // letterCounts == ["H": 1, "e": 2, "l": 4, "o": 1, ...]
868867
///
869-
/// When `letterCounts[letter, defaultValue: 0] += 1` is executed with a
868+
/// When `letterCounts[letter, default: 0] += 1` is executed with a
870869
/// value of `letter` that isn't already a key in `letterCounts`, the
871870
/// specified default value (`0`) is returned from the subscript,
872871
/// incremented, and then added to the dictionary under that key.

stdlib/public/core/FloatingPoint.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public protocol FloatingPoint: SignedNumeric, Strideable, Hashable
416416
/// let x = -33.375
417417
/// // x.sign == .minus
418418
///
419-
/// Do not use this property to check whether a floating point value is
419+
/// Don't use this property to check whether a floating point value is
420420
/// negative. For a value `x`, the comparison `x.sign == .minus` is not
421421
/// necessarily the same as `x < 0`. In particular, `x.sign == .minus` if
422422
/// `x` is -0, and while `x < 0` is always `false` if `x` is NaN, `x.sign`
@@ -1130,7 +1130,7 @@ public protocol FloatingPoint: SignedNumeric, Strideable, Hashable
11301130
/// A Boolean value indicating whether this instance is finite.
11311131
///
11321132
/// All values other than NaN and infinity are considered finite, whether
1133-
/// normal or subnormal.
1133+
/// normal or subnormal. For NaN, both `isFinite` and `isInfinite` are false.
11341134
var isFinite: Bool { get }
11351135

11361136
/// A Boolean value indicating whether the instance is equal to zero.
@@ -1147,7 +1147,7 @@ public protocol FloatingPoint: SignedNumeric, Strideable, Hashable
11471147
/// A Boolean value indicating whether the instance is subnormal.
11481148
///
11491149
/// A *subnormal* value is a nonzero number that has a lesser magnitude than
1150-
/// the smallest normal number. Subnormal values do not use the full
1150+
/// the smallest normal number. Subnormal values don't use the full
11511151
/// precision available to values of a type.
11521152
///
11531153
/// Zero is neither a normal nor a subnormal number. Subnormal numbers are
@@ -1157,8 +1157,7 @@ public protocol FloatingPoint: SignedNumeric, Strideable, Hashable
11571157

11581158
/// A Boolean value indicating whether the instance is infinite.
11591159
///
1160-
/// Note that `isFinite` and `isInfinite` do not form a dichotomy, because
1161-
/// they are not total: If `x` is `NaN`, then both properties are `false`.
1160+
/// For NaN, both `isFinite` and `isInfinite` are false.
11621161
var isInfinite: Bool { get }
11631162

11641163
/// A Boolean value indicating whether the instance is NaN ("not a number").

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public struct ${Self} {
9292
${Availability(bits)}
9393
extension ${Self}: CustomStringConvertible {
9494
/// A textual representation of the value.
95+
///
96+
/// For any finite value, this property provides a string that can be
97+
/// converted back to an instance of `${Self}` without rounding errors. That
98+
/// is, if `x` is an instance of `${Self}`, then `${Self}(x.description) ==
99+
/// x` is always true. For any NaN value, the property's value is "nan", and
100+
/// for positive and negative infinity its value is "inf" and "-inf".
95101
public var description: String {
96102
if isNaN {
97103
return "nan"
@@ -108,6 +114,9 @@ extension ${Self}: CustomStringConvertible {
108114
${Availability(bits)}
109115
extension ${Self}: CustomDebugStringConvertible {
110116
/// A textual representation of the value, suitable for debugging.
117+
///
118+
/// This property has the same value as the `description` property, except
119+
/// that NaN values are printed in an extended format.
111120
public var debugDescription: String {
112121
var (buffer, length) = _float${bits}ToString(self, debug: true)
113122
return buffer.withBytes { (bufferPtr) in

stdlib/public/core/Integers.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ extension ExpressibleByIntegerLiteral
5858
/// =============================================
5959
///
6060
/// To add `AdditiveArithmetic` protocol conformance to your own custom type,
61-
/// implement the required operators, and provide a static `zero` property
62-
/// using a type that can represent the magnitude of any value of your custom
63-
/// type.
61+
/// implement the required operators, and provide a static `zero` property.
6462
public protocol AdditiveArithmetic: Equatable {
6563
/// The zero value.
6664
///

stdlib/public/core/KeyPath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ internal func _abstract(
3030
// The two must coexist, so it was renamed. The old name must not be
3131
// used in the new runtime. _TtCs11_AnyKeyPath is the mangled name for
3232
// Swift._AnyKeyPath.
33-
@_objcRuntimeName(_TtCs11_AnyKeyPath)
3433

3534
/// A type-erased key path, from any root type to any resulting value
3635
/// type.
36+
@_objcRuntimeName(_TtCs11_AnyKeyPath)
3737
public class AnyKeyPath: Hashable, _AppendKeyPath {
3838
/// The root type for this key path.
3939
@inlinable

stdlib/public/core/ManagedBuffer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ extension ManagedBufferPointer {
376376
}
377377

378378
/// Returns `true` if `self` holds the only strong reference to its
379-
/// buffer. Otherwise, returns `false`.
379+
/// buffer; otherwise, returns `false`.
380380
///
381381
/// See `isKnownUniquelyReferenced` for details.
382382
@inlinable

stdlib/public/core/SIMDVector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ extension SIMD where Scalar: FixedWidthInteger {
815815
/// Returns the sum of the scalars in the vector, computed with wrapping
816816
/// addition.
817817
///
818-
/// Equivalent to indices.reduce(into: 0) { $0 &+= self[$1] }.
818+
/// Equivalent to `indices.reduce(into: 0) { $0 &+= self[$1] }`.
819819
@_alwaysEmitIntoClient
820820
public func wrappedSum() -> Scalar {
821821
return indices.reduce(into: 0) { $0 &+= self[$1] }

0 commit comments

Comments
 (0)