Skip to content

Commit 25f26e2

Browse files
Merge pull request #64514 from ZevEisenberg/patch-1
Add missing syntax highlighting, remove unnecessary indentation
2 parents 07efa25 + ef533b4 commit 25f26e2

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

CHANGELOG.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
3131
access to a value provided by the caller, or by `consuming` a value that the
3232
callee is allowed to take ownership of:
3333

34-
```
34+
```swift
3535
struct HealthyFoods {
3636
var values: [String] = []
3737

@@ -269,10 +269,10 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
269269
New types representing time and clocks were introduced. This includes a protocol `Clock` defining clocks which allow for defining a concept of now and a way to wake up after a given instant. Additionally a new protocol `InstantProtocol` for defining instants in time was added. Furthermore a new protocol `DurationProtocol` was added to define an elapsed duration between two given `InstantProtocol` types. Most commonly the `Clock` types for general use are the `SuspendingClock` and `ContinuousClock` which represent the most fundamental clocks for the system. The `SuspendingClock` type does not progress while the machine is suspended whereas the `ContinuousClock` progresses no matter the state of the machine.
270270

271271
```swift
272-
func delayedHello() async throws {
273-
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)
274-
print("hello delayed world")
275-
}
272+
func delayedHello() async throws {
273+
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)
274+
print("hello delayed world")
275+
}
276276
```
277277

278278
`Clock` also has methods to measure the elapsed duration of the execution of work. In the case of the `SuspendingClock` and `ContinuousClock` this measures with high resolution and is suitable for benchmarks.
@@ -294,17 +294,17 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
294294
`any` type having the same constraints as the associated type. For example:
295295

296296
```swift
297-
protocol Surface {...}
298-
299-
protocol Solid {
300-
associatedtype SurfaceType: Surface
301-
func boundary() -> SurfaceType
302-
}
303-
304-
let solid: any Solid = ...
305-
306-
// Type of 'boundary' is 'any Surface'
307-
let boundary = solid.boundary()
297+
protocol Surface {...}
298+
299+
protocol Solid {
300+
associatedtype SurfaceType: Surface
301+
func boundary() -> SurfaceType
302+
}
303+
304+
let solid: any Solid = ...
305+
306+
// Type of 'boundary' is 'any Surface'
307+
let boundary = solid.boundary()
308308
```
309309

310310
Protocol methods that take an associated type or `Self` cannot be used with `any`,
@@ -317,32 +317,32 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
317317
Protocols can now declare a list of one or more _primary associated types_, which enable writing same-type requirements on those associated types using angle bracket syntax:
318318

319319
```swift
320-
protocol Graph<Vertex, Edge> {
321-
associatedtype Vertex
322-
associatedtype Edge
323-
}
320+
protocol Graph<Vertex, Edge> {
321+
associatedtype Vertex
322+
associatedtype Edge
323+
}
324324
```
325325

326326
You can now write a protocol name followed by type arguments in angle brackets, like
327327
`Graph<Int, String>`, anywhere that a protocol conformance requirement may appear:
328328

329329
```swift
330-
func shortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
330+
func shortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
331331

332-
extension Graph<Int, String> {...}
332+
extension Graph<Int, String> {...}
333333

334-
func build() -> some Graph<Int, String> {}
334+
func build() -> some Graph<Int, String> {}
335335
```
336336

337337
A protocol name followed by angle brackets is shorthand for a conformance requirement,
338338
together with a same-type requirement for the protocol's primary associated types.
339339
The first two examples above are equivalent to the following:
340340

341341
```swift
342-
func shortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
343-
where G: Graph, G.Vertex == V, G.Edge == E
342+
func shortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
343+
where G: Graph, G.Vertex == V, G.Edge == E
344344

345-
extension Graph where Vertex == Int, Edge == String {...}
345+
extension Graph where Vertex == Int, Edge == String {...}
346346
```
347347

348348
The `build()` function returning `some Graph<Int, String>` can't be written using a

0 commit comments

Comments
 (0)