[Issue 22736] New: Add destructuring bind for std.typecons.Tuple tuples

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 4 19:41:50 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22736

          Issue ID: 22736
           Summary: Add destructuring bind for std.typecons.Tuple tuples
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: dlang-bugzilla at thecybershadow.net

auto bind(alias fun, T)(auto ref T tuple)
if (isTuple!T && is(typeof(fun(tuple.expand))))
{
        return fun(tuple.expand);
}

unittest
{
        immutable t = tuple(1, 2);
        auto sum = t.bind!((one, two) => one + two);
        assert(sum == 3);
}

--


More information about the Digitalmars-d-bugs mailing list