Просмотр исходного кода

Add "attempt_contextualised_select"

Billy Barrow 3 недель назад
Родитель
Сommit
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()