Skip to content

Commit ad5ffb9

Browse files
committed
SwiftCompilerSources: add Sequence.walk()
1 parent 9ddb60b commit ad5ffb9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

SwiftCompilerSources/Sources/SIL/Utilities/WalkUtils.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public enum WalkResult {
3838
case abortWalk
3939
}
4040

41+
extension Sequence {
42+
public func walk(
43+
_ predicate: (Element) throws -> WalkResult
44+
) rethrows -> WalkResult {
45+
return try contains { try predicate($0) == .abortWalk } ? .abortWalk : .continueWalk
46+
}
47+
}
48+
4149
/// The path which is updated throughout a walk.
4250
///
4351
/// Usually this is just a SmallProjectionPath, but clients can implement their own path, e.g.

0 commit comments

Comments
 (0)