We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f84dd82 commit ab9b599Copy full SHA for ab9b599
stdlib/public/core/CollectionOfOne.swift
@@ -70,6 +70,19 @@ extension CollectionOfOne.Iterator: IteratorProtocol {
70
}
71
72
73
+extension CollectionOfOne: Sequence {
74
+ // `mutating` since `withUnsafePointer` needs inout.
75
+ @inlinable // trivial-implementation
76
+ public mutating func withContiguousStorageIfAvailable<R>(
77
+ _ body: (UnsafeBufferPointer<Element>) throws -> R
78
+ ) rethrows -> R? {
79
+ return try withUnsafePointer(to: &_element) {
80
+ let buf = UnsafeBufferPointer(start: $0, count: 1)
81
+ return try body(buf)
82
+ }
83
84
+}
85
+
86
extension CollectionOfOne: RandomAccessCollection, MutableCollection {
87
88
public typealias Index = Int
0 commit comments