From 123b1c8f44081b66530fd107f0b0fa00f1464ac1 Mon Sep 17 00:00:00 2001 From: Ero Mrinin <47291495+EroMrinin134@users.noreply.github.com> Date: Wed, 9 Jul 2025 05:11:13 +0400 Subject: [PATCH] Added unpack macro for Triple (#2277) --- lib/std/collections/tuple.c3 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/std/collections/tuple.c3 b/lib/std/collections/tuple.c3 index 053a52034..07dece104 100644 --- a/lib/std/collections/tuple.c3 +++ b/lib/std/collections/tuple.c3 @@ -12,7 +12,6 @@ struct Pair @require $assignable(self.first, $typeof(*a)) : "You cannot assign the first value to a" @require $assignable(self.second, $typeof(*b)) : "You cannot assign the second value to b" *> - macro void Pair.unpack(&self, a, b) { *a = self.first; @@ -28,6 +27,21 @@ struct Triple Type3 third; } +<* + @param [&out] a + @param [&out] b + @param [&out] c + @require $assignable(self.first, $typeof(*a)) : "You cannot assign the first value to a" + @require $assignable(self.second, $typeof(*b)) : "You cannot assign the second value to b" + @require $assignable(self.third, $typeof(*c)) : "You cannot assign the second value to c" +*> +macro void Triple.unpack(&self, a, b, c) +{ + *a = self.first; + *b = self.second; + *c = self.third; +} + module std::collections::tuple{Type1, Type2}; struct Tuple @deprecated("Use 'Pair' instead")