Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ if (distinctFieldNames!(Specs))
// :
// NOTE: field[k] is an expression (which yields a symbol of a
// variable) and can't be aliased directly.
string injectNamedFields()
enum injectNamedFields = ()
{
string decl = "";
static foreach (i, val; fieldSpecs)
Expand All @@ -525,7 +525,7 @@ if (distinctFieldNames!(Specs))
}
}}
return decl;
}
};

// Returns Specs for a subtuple this[from .. to] preserving field
// names if any.
Expand Down Expand Up @@ -1498,6 +1498,26 @@ if (distinctFieldNames!(Specs))
assert(t == AliasSeq!(1, Bad(1), "asdf"));
}

// Ensure Tuple.toHash works
@safe unittest
{
Tuple!(int, int) point;
assert(point.toHash == typeof(point).init.toHash);
assert(tuple(1, 2) != point);
assert(tuple(1, 2) == tuple(1, 2));
point[0] = 1;
assert(tuple(1, 2) != point);
point[1] = 2;
assert(tuple(1, 2) == point);
}

@safe @betterC unittest
{
auto t = tuple(1, 2);
assert(t == tuple(1, 2));
auto t3 = tuple(1, 'd');
}

/**
Creates a copy of a $(LREF Tuple) with its fields in _reverse order.

Expand Down