Skip to content

Commit 86ad6b6

Browse files
committed
Documentation tweaks
1 parent bbdf99f commit 86ad6b6

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -584,31 +584,6 @@ struct Student: Codable {
584584
585585
> Using integer coding keys has the added benefit of better encoder/decoder performance. By explicitly indicating the field index, you let the decoder skip the functionality of matching coding keys string values to headers.
586586
587-
To generate type-safe name header rows you can use an enum with `String` rawValues.
588-
589-
```swift
590-
struct Student: Codable {
591-
var name: String
592-
var age: Int
593-
var hasPet: Bool
594-
595-
private enum CodingKeys: String, CodingKey, CaseIterable {
596-
case name = "name"
597-
case age = "age"
598-
case hasPet = "hasPet"
599-
}
600-
}
601-
```
602-
603-
Then configure your encoder with explicit headers.
604-
605-
```swift
606-
let encoder = CSVEncoder {
607-
$0.headers = Student.CodingKeys.allCases.map({ $0.rawValue })
608-
}
609-
```
610-
611-
612587
</p></details>
613588
<details><summary>A CSV is a long list of rows/records.</summary><p>
614589
@@ -758,6 +733,32 @@ decoder.nilStrategy = .custom({ (encoder) in
758733
759734
</p></details>
760735
736+
<details><summary>Type-safe headers row.</summary><p>
737+
738+
You can generate type-safe name headers using Swift introspection tools (i.e. `Mirror`) or explicitly defining the `CodingKey` enum with `String` raw value conforming to `CaseIterable`.
739+
740+
```swift
741+
struct Student {
742+
var name: String
743+
var age: Int
744+
var hasPet: Bool
745+
746+
enum CodingKeys: String, CodingKey, CaseIterable {
747+
case name, age, hasPet
748+
}
749+
}
750+
```
751+
752+
Then configure your encoder with explicit headers.
753+
754+
```swift
755+
let encoder = CSVEncoder {
756+
$0.headers = Student.CodingKeys.allCases.map { $0.rawValue }
757+
}
758+
```
759+
760+
</p></details>
761+
761762
<details><summary>Performance advices.</summary><p>
762763
763764
#warning("TODO:")

sources/imperative/reader/ReaderConfiguration.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ extension CSVReader {
1616
/// Trims the given characters at the beginning and end of each row, and between fields.
1717
public var trimStrategy: CharacterSet
1818
/// Boolean indicating whether the data/file/string should be completely parsed at reader's initialization.
19-
///
20-
/// Setting this property to `true` samples the data/file/string at initialization time. This process returns some interesting data such as blob/file size, full-file encoding validation, etc.
21-
/// The _presample_ process will however hurt performance since it iterates over all the data in initialization.
2219
public var presample: Bool
2320

2421
/// Designated initializer setting the default values.

0 commit comments

Comments
 (0)