Replace short preconditions in the main package

This commit is contained in:
2021-05-25 09:03:00 +02:00
parent b62cbb0647
commit 938a1bb5b4
23 changed files with 1024 additions and 295 deletions

View File

@ -170,7 +170,11 @@ if (isArray!Array)
void opCall(T)(auto ref T data)
if (is(T : E))
in (!this.data.empty)
in
{
assert(!this.data.empty);
}
do
{
put(this.data, data);
}

View File

@ -55,7 +55,11 @@ module tanya.range.array;
* Precondition: $(D_INLINECODE array.length > 0).
*/
@property ref inout(T) front(T)(return scope inout(T)[] array)
in (array.length > 0)
in
{
assert(array.length > 0);
}
do
{
return array[0];
}
@ -91,7 +95,11 @@ in (array.length > 0)
* Precondition: $(D_INLINECODE array.length > 0).
*/
@property ref inout(T) back(T)(return scope inout(T)[] array)
in (array.length > 0)
in
{
assert(array.length > 0);
}
do
{
return array[$ - 1];
}
@ -126,14 +134,22 @@ in (array.length > 0)
* Precondition: $(D_INLINECODE array.length > 0).
*/
void popFront(T)(scope ref inout(T)[] array)
in (array.length > 0)
in
{
assert(array.length > 0);
}
do
{
array = array[1 .. $];
}
/// ditto
void popBack(T)(scope ref inout(T)[] array)
in (array.length > 0)
in
{
assert(array.length > 0);
}
do
{
array = array[0 .. $ - 1];
}

View File

@ -1556,7 +1556,11 @@ if (isInputRange!Range && hasLvalueElements!Range)
*/
ElementType!R getAndPopFront(R)(ref R range)
if (isInputRange!R)
in (!range.empty)
in
{
assert(!range.empty);
}
do
{
static if (hasLvalueElements!R)
{
@ -1609,7 +1613,11 @@ in (!range.empty)
*/
auto ref getAndPopBack(R)(ref R range)
if (isBidirectionalRange!R)
in (!range.empty)
in
{
assert(!range.empty);
}
do
{
static if (hasLvalueElements!R)
{