-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathconsume_checking.swift
42 lines (37 loc) · 1.53 KB
/
consume_checking.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// RUN: %target-swift-frontend \
// RUN: -emit-sil -verify \
// RUN: %s \
// RUN: -sil-verify-all
////////////////////////////////////////////////////////////////////////////////
// https://github.com/apple/swift/issues/69252 {{
////////////////////////////////////////////////////////////////////////////////
public enum LineEnding: String {
/// The default unix `\n` character
case lineFeed = "\n"
/// MacOS line ending `\r` character
case carriageReturn = "\r"
/// Windows line ending sequence `\r\n`
case carriageReturnLineFeed = "\r\n"
/// Initialize a line ending from a line string.
/// - Parameter line: The line to use
public init?(line: borrowing String) {
guard let lastChar = line.last,
let lineEnding = LineEnding(rawValue: String(lastChar)) else { return nil }
self = lineEnding
}
static func makeLineEnding(_ line: borrowing String) -> LineEnding? {
guard let lastChar = line.last,
let lineEnding = LineEnding(rawValue: String(lastChar)) else { return nil }
_ = lineEnding
return nil
}
func makeLineEnding(_ line: borrowing String) -> LineEnding? {
guard let lastChar = line.last,
let lineEnding = LineEnding(rawValue: String(lastChar)) else { return nil }
_ = lineEnding
return nil
}
}
////////////////////////////////////////////////////////////////////////////////
// https://github.com/apple/swift/issues/69252 }}
////////////////////////////////////////////////////////////////////////////////