Files
Rauhul Varma 47fe00c4fe Enable more ci (#712)
Enables and fixes issues with additional platform tests 
and the formatter with these additional rules:

- UseLetInEveryBoundCaseVariable
- NeverForceUnwrap
- BeginDocumentationCommentWithOneLineSummary
- ValidateDocumentationComments
- AlwaysUseCamelCase
2025-02-12 08:52:17 -06:00

35 lines
973 B
Swift

//===----------------------------------------------------------*- swift -*-===//
//
// This source file is part of the Swift Argument Parser open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
extension Substring {
func trimmed() -> Substring {
guard let i = lastIndex(where: { $0 != " " }) else {
return ""
}
return self[...i]
}
}
extension String {
public func trimmingLines() -> String {
self
.split(separator: "\n", omittingEmptySubsequences: false)
.map { $0.trimmed() }
.joined(separator: "\n")
}
public func normalizingLineEndings() -> String {
self
.replacingOccurrences(of: "\r\n", with: "\n")
.replacingOccurrences(of: "\r", with: "\n")
}
}