Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladiwostok committed Oct 25, 2024
1 parent 7e63815 commit f65b563
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 21 deletions.
6 changes: 4 additions & 2 deletions std/algorithm/searching.d
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,8 @@ Returns:
The extreme value according to `map` and `selector` of the passed-in values.
*/
private auto extremum(alias map, alias selector = "a < b", Range)(Range r)
if (isInputRange!Range && !isInfinite!Range && is(typeof(unaryFun!map(ElementType!(Range).init))))
if (isInputRange!Range && !isInfinite!Range &&
is(typeof(unaryFun!map(ElementType!(Range).init))))
in
{
assert(!r.empty, "r is an empty range");
Expand Down Expand Up @@ -1424,7 +1425,8 @@ if (isInputRange!Range && !isInfinite!Range &&
}

private auto extremum(alias selector = "a < b", Range)(Range r)
if (isInputRange!Range && !isInfinite!Range && !is(typeof(unaryFun!selector(ElementType!(Range).init))))
if (isInputRange!Range && !isInfinite!Range &&
!is(typeof(unaryFun!selector(ElementType!(Range).init))))
{
return extremum!(a => a, selector)(r);
}
Expand Down
3 changes: 2 additions & 1 deletion std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,8 @@ if (isInputRange!RoR &&

/// Ditto
ElementEncodingType!(ElementType!RoR)[] join(RoR)(RoR ror)
if (isInputRange!RoR && isInputRange!(Unqual!(ElementType!RoR)))
if (isInputRange!RoR &&
isInputRange!(Unqual!(ElementType!RoR)))
{
alias RetType = typeof(return);
alias ConstRetTypeElement = ElementEncodingType!RetType;
Expand Down
24 changes: 16 additions & 8 deletions std/base64.d
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* ditto
*/
char[] encode(R1, R2)(R1 source, R2 buffer)
if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : ubyte) && hasLength!R1 && is(R2 == char[]))
if (!isArray!R1 && isInputRange!R1 &&
is(ElementType!R1 : ubyte) && hasLength!R1 &&
is(R2 == char[]))
in
{
assert(buffer.length >= encodeLength(source.length), "Insufficient buffer for encoding");
Expand Down Expand Up @@ -576,7 +578,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* ditto
*/
char[] encode(Range)(Range source)
if (!isArray!Range && isInputRange!Range && is(ElementType!Range : ubyte) && hasLength!Range)
if (!isArray!Range && isInputRange!Range &&
is(ElementType!Range : ubyte) && hasLength!Range)
{
return encode(source, new char[encodeLength(source.length)]);
}
Expand All @@ -593,7 +596,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* use the $(LREF encoder) function instead.
*/
struct Encoder(Range)
if (isInputRange!Range && (is(ElementType!Range : const(ubyte)[]) || is(ElementType!Range : const(char)[])))
if (isInputRange!Range && (is(ElementType!Range : const(ubyte)[]) ||
is(ElementType!Range : const(char)[])))
{
private:
Range range_;
Expand Down Expand Up @@ -984,7 +988,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
*/
@trusted
pure ubyte[] decode(R1, R2)(in R1 source, return scope R2 buffer)
if (isArray!R1 && is(ElementType!R1 : dchar) && is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
if (isArray!R1 && is(ElementType!R1 : dchar) &&
is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
in
{
assert(buffer.length >= realDecodeLength(source), "Insufficient buffer for decoding");
Expand Down Expand Up @@ -1068,8 +1073,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* ditto
*/
ubyte[] decode(R1, R2)(R1 source, R2 buffer)
if (!isArray!R1 && isInputRange!R1 && is(ElementType!R1 : dchar) && hasLength!R1
&& is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
if (!isArray!R1 && isInputRange!R1 &&
is(ElementType!R1 : dchar) && hasLength!R1 &&
is(R2 == ubyte[]) && isOutputRange!(R2, ubyte))
in
{
assert(buffer.length >= decodeLength(source.length), "Insufficient buffer for decoding");
Expand Down Expand Up @@ -1354,7 +1360,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* ditto
*/
ubyte[] decode(Range)(Range source)
if (!isArray!Range && isInputRange!Range && is(ElementType!Range : dchar) && hasLength!Range)
if (!isArray!Range && isInputRange!Range &&
is(ElementType!Range : dchar) && hasLength!Range)
{
return decode(source, new ubyte[decodeLength(source.length)]);
}
Expand All @@ -1371,7 +1378,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=')
* use the $(LREF decoder) function instead.
*/
struct Decoder(Range)
if (isInputRange!Range && (is(ElementType!Range : const(char)[]) || is(ElementType!Range : const(ubyte)[])))
if (isInputRange!Range && (is(ElementType!Range : const(char)[]) ||
is(ElementType!Range : const(ubyte)[])))
{
private:
Range range_;
Expand Down
7 changes: 5 additions & 2 deletions std/container/rbtree.d
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,8 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
* Complexity: $(BIGOH m * log(n))
*/
size_t stableInsert(Stuff)(scope Stuff stuff)
if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, Elem))
if (isInputRange!Stuff &&
isImplicitlyConvertible!(ElementType!Stuff, Elem))
{
size_t result = 0;
static if (allowDuplicates)
Expand Down Expand Up @@ -1565,7 +1566,9 @@ assert(equal(rbt[], [5]));

/++ Ditto +/
size_t removeKey(Stuff)(Stuff stuff)
if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, Elem) && !isDynamicArray!Stuff)
if (isInputRange!Stuff &&
isImplicitlyConvertible!(ElementType!Stuff, Elem) &&
!isDynamicArray!Stuff)
{
import std.array : array;
//We use array in case stuff is a Range from this RedBlackTree - either
Expand Down
6 changes: 4 additions & 2 deletions std/logger/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,10 @@ abstract class Logger
string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy A args)
if ((args.length > 1 && !is(Unqual!(A[0]) : bool)
&& !is(immutable A[0] == immutable LogLevel)) || args.length == 0)
if ((args.length > 1
&& !is(Unqual!(A[0]) : bool)
&& !is(immutable A[0] == immutable LogLevel))
|| args.length == 0)
{
synchronized (mutex)
{
Expand Down
3 changes: 2 additions & 1 deletion std/path.d
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,8 @@ private auto _withDefaultExtension(R, C)(R path, C[] ext)
of segments to assemble the path from.
Returns: The assembled path.
*/
immutable(ElementEncodingType!(ElementType!Range))[] buildPath(Range)(scope Range segments)
immutable(ElementEncodingType!(ElementType!Range))[]
buildPath(Range)(scope Range segments)
if (isInputRange!Range && !isInfinite!Range && isSomeString!(ElementType!Range))
{
if (segments.empty) return null;
Expand Down
5 changes: 3 additions & 2 deletions std/random.d
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ if (isFloatingPoint!(CommonType!(T1, T2)) && isUniformRNG!UniformRandomNumberGen
}

// Implementation of uniform for integral types
/** Description of algorithm and suggestion of correctness:
/+ Description of algorithm and suggestion of correctness:
The modulus operator maps an integer to a small, finite space. For instance, `x
% 3` will map whatever x is into the range [0 .. 3). 0 maps to 0, 1 maps to 1, 2
Expand Down Expand Up @@ -2215,7 +2215,8 @@ at least that number won't be represented fairly.
Hence, our condition to reroll is
`bucketFront > (UpperType.max - (upperDist - 1))`
*/
+/
/// ditto
auto uniform(string boundaries = "[)", T1, T2, RandomGen)
(T1 a, T2 b, ref RandomGen rng)
if ((isIntegral!(CommonType!(T1, T2)) || isSomeChar!(CommonType!(T1, T2))) &&
Expand Down
5 changes: 4 additions & 1 deletion std/stdio.d
Original file line number Diff line number Diff line change
Expand Up @@ -3015,7 +3015,10 @@ is empty, throws an `Exception`. In case of an I/O error throws

/// Range primitive implementations.
void put(A)(scope A writeme)
if ((isSomeChar!(ElementType!A) || is(ElementType!A : const(ubyte))) && isInputRange!A && !isInfinite!A)
if ((isSomeChar!(ElementType!A) ||
is(ElementType!A : const(ubyte))) &&
isInputRange!A &&
!isInfinite!A)
{
import std.exception : errnoEnforce;

Expand Down
6 changes: 4 additions & 2 deletions std/uni/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -7643,7 +7643,8 @@ public:

///ditto
this(Input)(Input seq)
if (!isDynamicArray!Input && isInputRange!Input && is(ElementType!Input : dchar))
if (!isDynamicArray!Input
&& isInputRange!Input && is(ElementType!Input : dchar))
{
this ~= seq;
}
Expand Down Expand Up @@ -9945,7 +9946,8 @@ private template toCaseLength(alias indexFn, uint maxIdx, alias tableFn)
// case-converted stuf to the new string
private template toCaseInPlaceAlloc(alias indexFn, uint maxIdx, alias tableFn)
{
void toCaseInPlaceAlloc(C)(ref C[] s, size_t curIdx, size_t destIdx) @trusted pure
void toCaseInPlaceAlloc(C)(ref C[] s, size_t curIdx,
size_t destIdx) @trusted pure
if (is(C == char) || is(C == wchar) || is(C == dchar))
{
import std.utf : decode;
Expand Down

0 comments on commit f65b563

Please sign in to comment.