소스 검색

Add "attempt_contextualised_select"

Billy Barrow 3 주 전
부모
커밋
0449cd0d0f
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      src/lib/Enumerable.vala

+ 7 - 0
src/lib/Enumerable.vala

@@ -151,6 +151,13 @@ namespace Invercargill {
             return select<Attempt<Tout>>(i => new Attempt<Tout>(() => transform(i))).assert_promotion<Attempts>();
         }
 
+        public virtual Attempts<SelectionContext<T, Tout>> attempt_contextualised_select<Tout>(owned AttemptTransformDelegate<T, Tout> transform) {
+            return attempt_select<SelectionContext<T, Tout>>((i) => new SelectionContext<T, Tout>() {
+                origin = i,
+                result = transform(i)
+            });
+        }
+
         public virtual Attempts<Tout> attempt_select_nested<Tout>(owned AttemptTransformDelegate<T, Enumerable<Attempt<Tout>>> transform) {
             return attempt_select<Enumerable<Attempt<Tout>>>((owned)transform)
                 .as_enumerable()