@@ -393,7 +393,7 @@ extension Graph {
393393 /// path and leaf value of each node are passed to the closure.
394394 ///
395395 /// - Throws: Whatever is thrown by `body`.
396- private func _forEach( keyPath: [ K ] , _ body: ( Element ) throws -> Void ) rethrows -> Void {
396+ private func _forEach< E > ( keyPath: [ K ] , _ body: ( Element ) throws ( E ) -> Void ) throws ( E ) {
397397 try body ( ( keyPath, value) )
398398 for (key, child) in children {
399399 var childKeyPath = keyPath
@@ -411,7 +411,7 @@ extension Graph {
411411 /// key path and leaf value of each node are passed to the closure.
412412 ///
413413 /// - Throws: Whatever is thrown by `body`.
414- private func _forEach( keyPath: [ K ] , _ body: ( Element ) async throws -> Void ) async rethrows -> Void {
414+ private func _forEach< E > ( keyPath: [ K ] , _ body: ( Element ) async throws ( E ) -> Void ) async throws ( E ) {
415415 try await body ( ( keyPath, value) )
416416 for (key, child) in children {
417417 var childKeyPath = keyPath
@@ -429,9 +429,9 @@ extension Graph {
429429 /// - Throws: Whatever is thrown by `body`.
430430 ///
431431 /// This function iterates depth-first.
432- func forEach( _ body: ( Element ) throws -> Void ) rethrows -> Void {
433- try _forEach ( keyPath: [ ] ) {
434- try body ( ( $0 , $1 ) )
432+ func forEach< E > ( _ body: ( Element ) throws ( E ) -> Void ) throws ( E ) {
433+ try _forEach ( keyPath: [ ] ) { ( element ) throws ( E ) in
434+ try body ( element )
435435 }
436436 }
437437
@@ -444,9 +444,9 @@ extension Graph {
444444 /// - Throws: Whatever is thrown by `body`.
445445 ///
446446 /// This function iterates depth-first.
447- func forEach( _ body: ( Element ) async throws -> Void ) async rethrows -> Void {
448- try await _forEach ( keyPath: [ ] ) {
449- try await body ( ( $0 , $1 ) )
447+ func forEach< E > ( _ body: ( Element ) async throws ( E ) -> Void ) async throws ( E ) {
448+ try await _forEach ( keyPath: [ ] ) { ( element ) async throws ( E ) in
449+ try await body ( element )
450450 }
451451 }
452452
@@ -496,9 +496,9 @@ extension Graph {
496496 /// - Throws: Whatever is thrown by `transform`.
497497 ///
498498 /// This function iterates depth-first.
499- func compactMapValues< U> ( _ transform: ( Element ) throws -> U ? ) rethrows -> Graph < K , U > ? {
500- try compactMapValues {
501- try transform ( $0 ) . map { ( $0, false ) }
499+ func compactMapValues< U, E > ( _ transform: ( Element ) throws ( E ) -> U ? ) throws ( E ) -> Graph < K , U > ? {
500+ try compactMapValues { ( element ) throws ( E ) in
501+ try transform ( element ) . map { ( $0, false ) }
502502 }
503503 }
504504
@@ -518,9 +518,9 @@ extension Graph {
518518 /// - Throws: Whatever is thrown by `transform`.
519519 ///
520520 /// This function iterates depth-first.
521- func compactMapValues< U> ( _ transform: ( Element ) async throws -> U ? ) async rethrows -> Graph < K , U > ? {
522- try await compactMapValues {
523- try await transform ( $0 ) . map { ( $0, false ) }
521+ func compactMapValues< U, E > ( _ transform: ( Element ) async throws ( E ) -> U ? ) async throws ( E ) -> Graph < K , U > ? {
522+ try await compactMapValues { ( element ) async throws ( E ) in
523+ try await transform ( element ) . map { ( $0, false ) }
524524 }
525525 }
526526
@@ -543,9 +543,9 @@ extension Graph {
543543 /// - Throws: Whatever is thrown by `transform`.
544544 ///
545545 /// This function iterates depth-first.
546- func compactMapValues< U> ( _ transform: ( Element ) throws -> ( U , recursivelyApply: Bool ) ? ) rethrows -> Graph < K , U > ? {
547- try _compactMapValues ( keyPath: [ ] ) {
548- try transform ( ( $0 , $1 ) )
546+ func compactMapValues< U, E > ( _ transform: ( Element ) throws ( E ) -> ( U , recursivelyApply: Bool ) ? ) throws ( E ) -> Graph < K , U > ? {
547+ try _compactMapValues ( keyPath: [ ] ) { ( element ) throws ( E ) in
548+ try transform ( element )
549549 }
550550 }
551551
@@ -563,7 +563,7 @@ extension Graph {
563563 /// child nodes are omitted from the new graph.
564564 ///
565565 /// - Throws: Whatever is thrown by `transform`.
566- private func _compactMapValues< U> ( keyPath: [ K ] , _ transform: ( Element ) throws -> ( U , recursivelyApply: Bool ) ? ) rethrows -> Graph < K , U > ? {
566+ private func _compactMapValues< U, E > ( keyPath: [ K ] , _ transform: ( Element ) throws ( E ) -> ( U , recursivelyApply: Bool ) ? ) throws ( E ) -> Graph < K , U > ? {
567567 guard let ( newValue, recursivelyApply) = try transform ( ( keyPath, value) ) else {
568568 return nil
569569 }
@@ -603,9 +603,9 @@ extension Graph {
603603 /// - Throws: Whatever is thrown by `transform`.
604604 ///
605605 /// This function iterates depth-first.
606- func compactMapValues< U> ( _ transform: ( Element ) async throws -> ( U , recursivelyApply: Bool ) ? ) async rethrows -> Graph < K , U > ? {
607- try await _compactMapValues ( keyPath: [ ] ) {
608- try await transform ( ( $0 , $1 ) )
606+ func compactMapValues< U, E > ( _ transform: ( Element ) async throws ( E ) -> ( U , recursivelyApply: Bool ) ? ) async throws ( E ) -> Graph < K , U > ? {
607+ try await _compactMapValues ( keyPath: [ ] ) { ( element ) async throws ( E ) in
608+ try await transform ( element )
609609 }
610610 }
611611
@@ -623,7 +623,7 @@ extension Graph {
623623 /// child nodes are omitted from the new graph.
624624 ///
625625 /// - Throws: Whatever is thrown by `transform`.
626- private func _compactMapValues< U> ( keyPath: [ K ] , _ transform: ( Element ) async throws -> ( U , recursivelyApply: Bool ) ? ) async rethrows -> Graph < K , U > ? {
626+ private func _compactMapValues< U, E > ( keyPath: [ K ] , _ transform: ( Element ) async throws ( E ) -> ( U , recursivelyApply: Bool ) ? ) async throws ( E ) -> Graph < K , U > ? {
627627 guard let ( newValue, recursivelyApply) = try await transform ( ( keyPath, value) ) else {
628628 return nil
629629 }
@@ -658,7 +658,7 @@ extension Graph {
658658 /// - Throws: Whatever is thrown by `transform`.
659659 ///
660660 /// This function iterates depth-first.
661- func mapValues< U> ( _ transform: ( Element ) throws -> U ) rethrows -> Graph < K , U > {
661+ func mapValues< U, E > ( _ transform: ( Element ) throws ( E ) -> U ) throws ( E ) -> Graph < K , U > {
662662 try compactMapValues ( transform) !
663663 }
664664
@@ -676,7 +676,7 @@ extension Graph {
676676 /// - Throws: Whatever is thrown by `transform`.
677677 ///
678678 /// This function iterates depth-first.
679- func mapValues< U> ( _ transform: ( Element ) async throws -> U ) async rethrows -> Graph < K , U > {
679+ func mapValues< U, E > ( _ transform: ( Element ) async throws ( E ) -> U ) async throws ( E ) -> Graph < K , U > {
680680 try await compactMapValues ( transform) !
681681 }
682682
@@ -698,7 +698,7 @@ extension Graph {
698698 /// - Throws: Whatever is thrown by `transform`.
699699 ///
700700 /// This function iterates depth-first.
701- func mapValues< U> ( _ transform: ( Element ) throws -> ( U , recursivelyApply: Bool ) ) rethrows -> Graph < K , U > {
701+ func mapValues< U, E > ( _ transform: ( Element ) throws ( E ) -> ( U , recursivelyApply: Bool ) ) throws ( E ) -> Graph < K , U > {
702702 try compactMapValues ( transform) !
703703 }
704704
@@ -720,7 +720,7 @@ extension Graph {
720720 /// - Throws: Whatever is thrown by `transform`.
721721 ///
722722 /// This function iterates depth-first.
723- func mapValues< U> ( _ transform: ( Element ) async throws -> ( U , recursivelyApply: Bool ) ) async rethrows -> Graph < K , U > {
723+ func mapValues< U, E > ( _ transform: ( Element ) async throws ( E ) -> ( U , recursivelyApply: Bool ) ) async throws ( E ) -> Graph < K , U > {
724724 try await compactMapValues ( transform) !
725725 }
726726
@@ -738,7 +738,7 @@ extension Graph {
738738 /// - Throws: Whatever is thrown by `transform`.
739739 ///
740740 /// This function iterates depth-first.
741- func map< U> ( _ transform: ( Element ) throws -> U ) rethrows -> [ U ] {
741+ func map< U, E > ( _ transform: ( Element ) throws ( E ) -> U ) throws ( E ) -> [ U ] {
742742 try compactMap ( transform)
743743 }
744744
@@ -756,7 +756,7 @@ extension Graph {
756756 /// - Throws: Whatever is thrown by `transform`.
757757 ///
758758 /// This function iterates depth-first.
759- func map< U> ( _ transform: ( Element ) async throws -> U ) async rethrows -> [ U ] {
759+ func map< U, E > ( _ transform: ( Element ) async throws ( E ) -> U ) async throws ( E ) -> [ U ] {
760760 try await compactMap ( transform)
761761 }
762762
@@ -776,10 +776,10 @@ extension Graph {
776776 /// - Throws: Whatever is thrown by `transform`.
777777 ///
778778 /// This function iterates depth-first.
779- func compactMap< U> ( _ transform: ( Element ) throws -> U ? ) rethrows -> [ U ] {
779+ func compactMap< U, E > ( _ transform: ( Element ) throws ( E ) -> U ? ) throws ( E ) -> [ U ] {
780780 var result = [ U] ( )
781781
782- try forEach { keyPath, value in
782+ try forEach { ( keyPath, value) throws ( E ) in
783783 if let newValue = try transform ( ( keyPath, value) ) {
784784 result. append ( newValue)
785785 }
@@ -804,10 +804,10 @@ extension Graph {
804804 /// - Throws: Whatever is thrown by `transform`.
805805 ///
806806 /// This function iterates depth-first.
807- func compactMap< U> ( _ transform: ( Element ) async throws -> U ? ) async rethrows -> [ U ] {
807+ func compactMap< U, E > ( _ transform: ( Element ) async throws ( E ) -> U ? ) async throws ( E ) -> [ U ] {
808808 var result = [ U] ( )
809809
810- try await forEach { keyPath, value in
810+ try await forEach { ( keyPath, value) async throws ( E ) in
811811 if let newValue = try await transform ( ( keyPath, value) ) {
812812 result. append ( newValue)
813813 }
@@ -829,7 +829,7 @@ extension Graph {
829829 /// - Throws: Whatever is thrown by `transform`.
830830 ///
831831 /// This function iterates depth-first.
832- func flatMap< S> ( _ transform: ( Element ) throws -> S ) rethrows -> [ S . Element ] where S: Sequence {
832+ func flatMap< S, E > ( _ transform: ( Element ) throws ( E ) -> S ) throws ( E ) -> [ S . Element ] where S: Sequence {
833833 try map ( transform) . flatMap { $0 }
834834 }
835835
@@ -846,7 +846,7 @@ extension Graph {
846846 /// - Throws: Whatever is thrown by `transform`.
847847 ///
848848 /// This function iterates depth-first.
849- func flatMap< S> ( _ transform: ( Element ) async throws -> S ) async rethrows -> [ S . Element ] where S: Sequence {
849+ func flatMap< S, E > ( _ transform: ( Element ) async throws ( E ) -> S ) async throws ( E ) -> [ S . Element ] where S: Sequence {
850850 try await map ( transform) . flatMap { $0 }
851851 }
852852}
0 commit comments