Skip to content

Revert "Move String additions from _FoundationInternals to FoundationEssentials + package" #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ extension Substring {
}

// Only throws when using `.regularExpression` option
package func _enumerateComponents(separatedBy separator: Substring, options: String.CompareOptions, withBlock block: (_ component: Substring, _ isLastComponent: Bool) -> ()) throws {
func _enumerateComponents(separatedBy separator: Substring, options: String.CompareOptions = [], withBlock block: (_ component: Substring, _ isLastComponent: Bool) -> ()) throws {
var searchStart = startIndex
while searchStart < endIndex {
let r = try self[searchStart...]._range(of: separator, options: options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
//===----------------------------------------------------------------------===//

extension String {
package func _trimmingWhitespace() -> String {
internal func _trimmingWhitespace() -> String {
String(unicodeScalars._trimmingCharacters {
$0.properties.isWhitespace
})
}

package init?(_utf16 input: UnsafeBufferPointer<UInt16>) {
internal init?(_utf16 input: UnsafeBufferPointer<UInt16>) {
// Allocate input.count * 3 code points since one UTF16 code point may require up to three UTF8 code points when transcoded
let str = withUnsafeTemporaryAllocation(of: UTF8.CodeUnit.self, capacity: input.count * 3) { contents in
var count = 0
Expand All @@ -39,14 +39,14 @@ extension String {
self = str
}

package init?(_utf16 input: UnsafeMutableBufferPointer<UInt16>, count: Int) {
internal init?(_utf16 input: UnsafeMutableBufferPointer<UInt16>, count: Int) {
guard let str = String(_utf16: UnsafeBufferPointer(rebasing: input[..<count])) else {
return nil
}
self = str
}

package init?(_utf16 input: UnsafePointer<UInt16>, count: Int) {
internal init?(_utf16 input: UnsafePointer<UInt16>, count: Int) {
guard let str = String(_utf16: UnsafeBufferPointer(start: input, count: count)) else {
return nil
}
Expand Down