Skip to content

Commit ffcc833

Browse files
committed
Add Example section
Signed-off-by: Gray Campbell <12163070+graycampbell@users.noreply.github.com>
1 parent 55c71f5 commit ffcc833

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
22

33
SwiftSyntaxSugar is a library that provides syntactic sugar and helpful extensions for [SwiftSyntax](https://github.com/swiftlang/swift-syntax). The purpose of this library is to improve the readability and maintainability of code written using SwiftSyntax.
44

5+
- [Example](#example)
6+
- [Installation](#installation)
7+
- [License](#license)
8+
9+
## Example
10+
11+
<table style="width: 100%; table-layout: fixed;">
12+
<tr>
13+
<td> With <code>SwiftSyntaxSugar</code> </td>
14+
<td> Without <code>SwiftSyntaxSugar</code> </td>
15+
</tr>
16+
<tr>
17+
<td style="width: 50%;">
18+
19+
```swift
20+
protocolDeclaration.isActorConstrained
21+
```
22+
23+
</td>
24+
<td style="width: 50%;">
25+
26+
```swift
27+
let isProtocolActorConstrained = protocolDeclaration.inheritanceClause?.inheritedTypes.contains { inheritedType in
28+
let identifierType = inheritedType.type.as(IdentifierTypeSyntax.self)
29+
return identifierType.name.tokenKind == .identifier("Actor")
30+
} ?? false
31+
```
32+
33+
</td>
34+
</tr>
35+
</table>
36+
537
## Installation
638

739
To add SwiftSyntaxSugar to a Swift package manifest file:

0 commit comments

Comments
 (0)