Skip to content

Commit

Permalink
deprecate: LuaMultiReturn
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyChatha committed May 3, 2023
1 parent 9655607 commit c2c63b2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions source/lumars/function_.d
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct LuaVariadic
}

// (replacing with Tuple soon, not documenting)
deprecated("Deprecated in favour of using std.typecons.Tuple")
struct LuaMultiReturn(T...)
{
alias ValueTuple = T;
Expand Down Expand Up @@ -775,12 +776,14 @@ unittest

unittest
{
import std.typecons : tuple;

auto lua = new LuaState(null);
lua.register!(
luaOverloads!(
(int a) { assert(a == 1); return a; },
(string a) { assert(a == "2"); return a; },
(int a, string b) { assert(a == 1); assert(b == "2"); return LuaMultiReturn!(int, string)(a, b); }
(int a, string b) { assert(a == 1); assert(b == "2"); return tuple(a, b); }
)
)("overloaded");
lua.doString(`
Expand All @@ -794,9 +797,11 @@ unittest

unittest
{
static LuaMultiReturn!(int, string, bool) multiReturn()
import std.typecons : tuple;

static auto multiReturn()
{
return typeof(return)(20, "40", true);
return tuple(20, "40", true);
}

auto lua = new LuaState(null);
Expand Down Expand Up @@ -887,13 +892,15 @@ unittest

unittest
{
import std.typecons : tuple;

auto lua = new LuaState(null);
lua.register!(
"normal", (){ return 1; },
"overloaded", luaOverloads!(
(int a) { assert(a == 1); return a; },
(string a) { assert(a == "2"); return a; },
(int a, string b) { assert(a == 1); assert(b == "2"); return LuaMultiReturn!(int, string)(a, b); }
(int a, string b) { assert(a == 1); assert(b == "2"); return tuple(a, b); }
)
)("lib");

Expand Down

0 comments on commit c2c63b2

Please sign in to comment.