February 04, 2022 [Issue 22736] New: Add destructuring bind for std.typecons.Tuple tuples | ||||
|---|---|---|---|---|
| ||||
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@puremagic.com Reporter: dlang-bugzilla@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); } -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply