Skip to content

Commit 5d744e2

Browse files
authored
Merge branch 'main' into em_dash_102987894
2 parents edfd4dd + caa5009 commit 5d744e2

17 files changed

+119
-77
lines changed

Sources/TSPL/TSPL.docc/LanguageGuide/AutomaticReferenceCounting.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,9 @@ and ARC never sets an unowned reference's value to `nil`.
601601
-->
602602

603603
> Important: Use an unowned reference only when you are sure that
604-
> the reference *always* refers to an instance that hasn't been deallocated.If you try to access the value of an unowned reference
604+
> the reference *always* refers to an instance that hasn't been deallocated.
605+
>
606+
> If you try to access the value of an unowned reference
605607
> after that instance has been deallocated,
606608
> you'll get a runtime error.
607609
@@ -768,7 +770,9 @@ after the `john` variable is set to `nil`.
768770
> you need to disable runtime safety checks ---
769771
> for example, for performance reasons.
770772
> As with all unsafe operations,
771-
> you take on the responsibility for checking that code for safety.You indicate an unsafe unowned reference by writing `unowned(unsafe)`.
773+
> you take on the responsibility for checking that code for safety.
774+
>
775+
> You indicate an unsafe unowned reference by writing `unowned(unsafe)`.
772776
> If you try to access an unsafe unowned reference
773777
> after the instance that it refers to is deallocated,
774778
> your program will try to access the memory location
@@ -909,7 +913,9 @@ that other courses might have.
909913
> Note: The underlying type of an optional value is `Optional`,
910914
> which is an enumeration in the Swift standard library.
911915
> However, optionals are an exception to the rule that
912-
> value types can't be marked with `unowned`.The optional that wraps the class
916+
> value types can't be marked with `unowned`.
917+
>
918+
> The optional that wraps the class
913919
> doesn't use reference counting,
914920
> so you don't need to maintain a strong reference to the optional.
915921

Sources/TSPL/TSPL.docc/LanguageGuide/Closures.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,9 @@ the next time the `incrementer` function is called.
731731
> Note: As an optimization,
732732
> Swift may instead capture and store a *copy* of a value
733733
> if that value isn't mutated by a closure,
734-
> and if the value isn't mutated after the closure is created.Swift also handles all memory management involved in disposing of
734+
> and if the value isn't mutated after the closure is created.
735+
>
736+
> Swift also handles all memory management involved in disposing of
735737
> variables when they're no longer needed.
736738
737739
Here's an example of `makeIncrementer` in action:

Sources/TSPL/TSPL.docc/LanguageGuide/CollectionTypes.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ and its size and contents can't be changed.
5454
An *array* stores values of the same type in an ordered list.
5555
The same value can appear in an array multiple times at different positions.
5656

57-
> Note: Swift's `Array` type is bridged to Foundation's `NSArray` class.For more information about using `Array` with Foundation and Cocoa,
57+
> Note: Swift's `Array` type is bridged to Foundation's `NSArray` class.
58+
>
59+
> For more information about using `Array` with Foundation and Cocoa,
5860
> see [Bridging Between Array and NSArray](https://developer.apple.com/documentation/swift/array#2846730).
5961
6062
### Array Type Shorthand Syntax
@@ -580,7 +582,9 @@ in a collection with no defined ordering.
580582
You can use a set instead of an array when the order of items isn't important,
581583
or when you need to ensure that an item only appears once.
582584

583-
> Note: Swift's `Set` type is bridged to Foundation's `NSSet` class.For more information about using `Set` with Foundation and Cocoa,
585+
> Note: Swift's `Set` type is bridged to Foundation's `NSSet` class.
586+
>
587+
> For more information about using `Set` with Foundation and Cocoa,
584588
> see [Bridging Between Set and NSSet](https://developer.apple.com/documentation/swift/set#2845530).
585589
586590
<!--
@@ -605,7 +609,7 @@ are also hashable by default.
605609
> by making them conform to the `Hashable` protocol
606610
> from the Swift standard library.
607611
> For information about implementing the required `hash(into:)` method,
608-
> see [Hashable](https://developer.apple.com/documentation/swift/hashable).
612+
> see [`Hashable`](https://developer.apple.com/documentation/swift/hashable).
609613
> For information about conforming to protocols, see <doc:Protocols>.
610614
611615
### Set Type Syntax
@@ -1027,7 +1031,9 @@ You use a dictionary when you need to look up values based on their identifier,
10271031
in much the same way that a real-world dictionary is used to look up
10281032
the definition for a particular word.
10291033

1030-
> Note: Swift's `Dictionary` type is bridged to Foundation's `NSDictionary` class.For more information about using `Dictionary` with Foundation and Cocoa,
1034+
> Note: Swift's `Dictionary` type is bridged to Foundation's `NSDictionary` class.
1035+
>
1036+
> For more information about using `Dictionary` with Foundation and Cocoa,
10311037
> see [Bridging Between Dictionary and NSDictionary](https://developer.apple.com/documentation/swift/dictionary#2846239).
10321038
10331039
### Dictionary Type Shorthand Syntax

Sources/TSPL/TSPL.docc/LanguageGuide/Concurrency.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ you'll get compile-time error instead of introducing a bug.
297297
and give you better guarantees and clearer errors
298298
-->
299299

300-
> Note: The [Task.sleep(until:tolerance:clock:)](https://developer.apple.com/documentation/swift/task/sleep(until:tolerance:clock:)) method
300+
> Note: The [`Task.sleep(until:tolerance:clock:)`](https://developer.apple.com/documentation/swift/task/sleep(until:tolerance:clock:)) method
301301
> is useful when writing simple code
302302
> to learn how concurrency works.
303303
> This method does nothing,
@@ -388,10 +388,10 @@ when it's waiting for the next element to be available.
388388
-->
389389

390390
In the same way that you can use your own types in a `for`-`in` loop
391-
by adding conformance to the [Sequence](https://developer.apple.com/documentation/swift/sequence) protocol,
391+
by adding conformance to the [`Sequence`](https://developer.apple.com/documentation/swift/sequence) protocol,
392392
you can use your own types in a `for`-`await`-`in` loop
393393
by adding conformance to the
394-
[AsyncSequence](https://developer.apple.com/documentation/swift/asyncsequence) protocol.
394+
[`AsyncSequence`](https://developer.apple.com/documentation/swift/asyncsequence) protocol.
395395

396396
<!--
397397
TODO what happened to ``Series`` which was supposed to be a currency type?
@@ -554,7 +554,7 @@ Because of the explicit relationship between tasks and task groups,
554554
this approach is called *structured concurrency*.
555555
Although you take on some of the responsibility for correctness,
556556
the explicit parent-child relationships between tasks
557-
lets Swift handle some behaviors like propagating cancellation for you,
557+
let Swift handle some behaviors like propagating cancellation for you,
558558
and lets Swift detect some errors at compile time.
559559

560560
```
@@ -571,7 +571,7 @@ await withTaskGroup(of: Data.self) { taskGroup in
571571
-->
572572

573573
For more information about task groups,
574-
see [TaskGroup](https://developer.apple.com/documentation/swift/taskgroup).
574+
see [`TaskGroup`](https://developer.apple.com/documentation/swift/taskgroup).
575575

576576
<!--
577577
OUTLINE
@@ -699,10 +699,10 @@ You have complete flexibility to manage unstructured tasks
699699
in whatever way your program needs,
700700
but you're also completely responsible for their correctness.
701701
To create an unstructured task that runs on the current actor,
702-
call the [Task.init(priority:operation:)](https://developer.apple.com/documentation/swift/task/3856790-init) initializer.
702+
call the [`Task.init(priority:operation:)`](https://developer.apple.com/documentation/swift/task/3856790-init) initializer.
703703
To create an unstructured task that's not part of the current actor,
704704
known more specifically as a *detached task*,
705-
call the [Task.detached(priority:operation:)](https://developer.apple.com/documentation/swift/task/3856786-detached) class method.
705+
call the [`Task.detached(priority:operation:)`](https://developer.apple.com/documentation/swift/task/3856786-detached) class method.
706706
Both of these operations return a task that you can interact with ---
707707
for example, to wait for its result or to cancel it.
708708

@@ -715,7 +715,7 @@ let result = await handle.value
715715
```
716716

717717
For more information about managing detached tasks,
718-
see [Task](https://developer.apple.com/documentation/swift/task).
718+
see [`Task`](https://developer.apple.com/documentation/swift/task).
719719

720720
<!--
721721
TODO Add some conceptual guidance about
@@ -738,16 +738,16 @@ that usually means one of the following:
738738
- Returning the partially completed work
739739

740740
To check for cancellation,
741-
either call [Task.checkCancellation()](https://developer.apple.com/documentation/swift/task/3814826-checkcancellation),
741+
either call [`Task.checkCancellation()`](https://developer.apple.com/documentation/swift/task/3814826-checkcancellation),
742742
which throws `CancellationError` if the task has been canceled,
743-
or check the value of [Task.isCancelled](https://developer.apple.com/documentation/swift/task/3814832-iscancelled)
743+
or check the value of [`Task.isCancelled`](https://developer.apple.com/documentation/swift/task/3814832-iscancelled)
744744
and handle the cancellation in your own code.
745745
For example,
746746
a task that's downloading photos from a gallery
747747
might need to delete partial downloads and close network connections.
748748

749749
To propagate cancellation manually,
750-
call [Task.cancel()](https://developer.apple.com/documentation/swift/task/3851218-cancel).
750+
call [`Task.cancel()`](https://developer.apple.com/documentation/swift/task/3851218-cancel).
751751

752752
<!--
753753
OUTLINE
@@ -1040,7 +1040,7 @@ In general, there are three ways for a type to be sendable:
10401040
-->
10411041

10421042
For a detailed list of the semantic requirements,
1043-
see the [Sendable](https://developer.apple.com/documentation/swift/sendable) protocol reference.
1043+
see the [`Sendable`](https://developer.apple.com/documentation/swift/sendable) protocol reference.
10441044

10451045
Some types are always sendable,
10461046
like structures that have only sendable properties

Sources/TSPL/TSPL.docc/LanguageGuide/ControlFlow.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ The examples above use a `for`-`in` loop to iterate
274274
ranges, arrays, dictionaries, and strings.
275275
However, you can use this syntax to iterate *any* collection,
276276
including your own classes and collection types,
277-
as long as those types conform to the [Sequence](https://developer.apple.com/documentation/swift/sequence) protocol.
277+
as long as those types conform to the [`Sequence`](https://developer.apple.com/documentation/swift/sequence) protocol.
278278

279279
<!--
280280
TODO: for (index, object) in enumerate(collection)
@@ -1732,9 +1732,11 @@ and to determine whether the move is allowed:
17321732

17331733
> Note: If the `break` statement above didn't use the `gameLoop` label,
17341734
> it would break out of the `switch` statement, not the `while` statement.
1735-
> Using the `gameLoop` label makes it clear which control statement should be terminated.It isn't strictly necessary to use the `gameLoop` label
1735+
> Using the `gameLoop` label makes it clear which control statement should be terminated.
1736+
>
1737+
> It isn't strictly necessary to use the `gameLoop` label
17361738
> when calling `continue gameLoop` to jump to the next iteration of the loop.
1737-
> there's only one loop in the game,
1739+
> There's only one loop in the game,
17381740
> and therefore no ambiguity as to which loop the `continue` statement will affect.
17391741
> However, there's no harm in using the `gameLoop` label with the `continue` statement.
17401742
> Doing so is consistent with the label's use alongside the `break` statement

Sources/TSPL/TSPL.docc/LanguageGuide/Enumerations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ for beverage in Beverage.allCases {
307307

308308
The syntax used in the examples above
309309
marks the enumeration as conforming to the
310-
[CaseIterable](https://developer.apple.com/documentation/swift/caseiterable) protocol.
310+
[`CaseIterable`](https://developer.apple.com/documentation/swift/caseiterable) protocol.
311311
For information about protocols, see <doc:Protocols>.
312312

313313
## Associated Values

Sources/TSPL/TSPL.docc/LanguageGuide/Inheritance.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,9 @@ For more information on property observers, see <doc:Properties#Property-Observe
435435
> inherited constant stored properties or inherited read-only computed properties.
436436
> The value of these properties can't be set,
437437
> and so it isn't appropriate to provide a `willSet` or `didSet` implementation
438-
> as part of an override.Note also that you can't provide both
438+
> as part of an override.
439+
>
440+
> Note also that you can't provide both
439441
> an overriding setter and an overriding property observer for the same property.
440442
> If you want to observe changes to a property's value,
441443
> and you are already providing a custom setter for that property,

Sources/TSPL/TSPL.docc/LanguageGuide/MemorySafety.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ you have to determine what it was intended to do.
112112
> However,
113113
> the conflicting access discussed here can happen
114114
> on a single thread and
115-
> *doesn't* involve concurrent or multithreaded code.If you have conflicting access to memory
115+
> *doesn't* involve concurrent or multithreaded code.
116+
>
117+
> If you have conflicting access to memory
116118
> from within a single thread,
117119
> Swift guarantees that you'll get an error
118120
> at either compile time or runtime.

Sources/TSPL/TSPL.docc/LanguageGuide/Properties.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,9 @@ the new value that you assign replaces the one that was just set.
737737
> are called when a property is set in a subclass initializer,
738738
> after the superclass initializer has been called.
739739
> They aren't called while a class is setting its own properties,
740-
> before the superclass initializer has been called.For more information about initializer delegation,
740+
> before the superclass initializer has been called.
741+
>
742+
> For more information about initializer delegation,
741743
> see <doc:Initialization#Initializer-Delegation-for-Value-Types>
742744
> and <doc:Initialization#Initializer-Delegation-for-Class-Types>.
743745
@@ -1676,7 +1678,9 @@ and they're written in the same way as computed properties.
16761678
> Note: Global constants and variables are always computed lazily,
16771679
> in a similar manner to <doc:Properties#Lazy-Stored-Properties>.
16781680
> Unlike lazy stored properties,
1679-
> global constants and variables don't need to be marked with the `lazy` modifier.Local constants and variables are never computed lazily.
1681+
> global constants and variables don't need to be marked with the `lazy` modifier.
1682+
>
1683+
> Local constants and variables are never computed lazily.
16801684
16811685
You can apply a property wrapper to a local stored variable,
16821686
but not to a global variable or a computed variable.
@@ -1763,7 +1767,9 @@ in the same way as computed instance properties.
17631767
> Note: Unlike stored instance properties,
17641768
> you must always give stored type properties a default value.
17651769
> This is because the type itself doesn't have an initializer
1766-
> that can assign a value to a stored type property at initialization time.Stored type properties are lazily initialized on their first access.
1770+
> that can assign a value to a stored type property at initialization time.
1771+
>
1772+
> Stored type properties are lazily initialized on their first access.
17671773
> They're guaranteed to be initialized only once,
17681774
> even when accessed by multiple threads simultaneously,
17691775
> and they don't need to be marked with the `lazy` modifier.

Sources/TSPL/TSPL.docc/LanguageGuide/StringsAndCharacters.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ and provides support for accessing those characters in various Unicode represent
2929
> Note: Swift's `String` type is bridged with Foundation's `NSString` class.
3030
> Foundation also extends `String` to expose methods defined by `NSString`.
3131
> This means, if you import Foundation,
32-
> you can access those `NSString` methods on `String` without casting.For more information about using `String` with Foundation and Cocoa,
32+
> you can access those `NSString` methods on `String` without casting.
33+
>
34+
> For more information about using `String` with Foundation and Cocoa,
3335
> see [Bridging Between String and NSString](https://developer.apple.com/documentation/swift/string#2919514).
3436
3537
## String Literals
@@ -958,7 +960,9 @@ print("the number of characters in \(word) is \(word.count)")
958960
> If you are working with particularly long string values,
959961
> be aware that the `count` property
960962
> must iterate over the Unicode scalars in the entire string
961-
> in order to determine the characters for that string.The count of the characters returned by the `count` property
963+
> in order to determine the characters for that string.
964+
>
965+
> The count of the characters returned by the `count` property
962966
> isn't always the same as the `length` property of
963967
> an `NSString` that contains the same characters.
964968
> The length of an `NSString` is based on
@@ -1173,7 +1177,7 @@ welcome.removeSubrange(range)
11731177
When you get a substring from a string ---
11741178
for example, using a subscript or a method like `prefix(_:)` ---
11751179
the result is an instance
1176-
of [Substring](https://developer.apple.com/documentation/swift/substring),
1180+
of [`Substring`](https://developer.apple.com/documentation/swift/substring),
11771181
not another string.
11781182
Substrings in Swift have most of the same methods as strings,
11791183
which means you can work with substrings
@@ -1249,7 +1253,7 @@ The figure below shows these relationships:
12491253
![](stringSubstring)
12501254

12511255
> Note: Both `String` and `Substring` conform to the
1252-
> [StringProtocol](https://developer.apple.com/documentation/swift/stringprotocol) protocol,
1256+
> [`StringProtocol`](https://developer.apple.com/documentation/swift/stringprotocol) protocol,
12531257
> which means it's often convenient for string-manipulation functions
12541258
> to accept a `StringProtocol` value.
12551259
> You can call such functions with either a `String` or `Substring` value.

0 commit comments

Comments
 (0)