Skip to content
Merged
Show file tree
Hide file tree
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
54 changes: 54 additions & 0 deletions changelog/pattern-deprecate.dd
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,57 @@ $(MREF std, regex) and $(MREF std, algorithm). They will be removed from
$(MREF std, string) on May 2018.

If you still need to use these, please see $(LINK2 https://github.com/dlang/undeaD, undeaD).

The following are examples of the deprecated functions, and their modern replacements.

Use $(REF find, std, algorithm, searching) to replace $(REF munch, std, string):
-------
import std.algorithm;
import std.ascii;
import std.string;
import std.utf;

string s = "\tabc";

// old
s.munch(whitespace);

// new
s = s.find!(a => !isWhite(a));
-------

Use $(REF matchFirst, std, regex) to replace $(REF inPattern, std, string):
-------
import std.string;
import std.regex;

// old
if (inPattern('x', "a-z")) { ... }

// new
if ("x".matchFirst(regex("[a-z]"))) { ... }
-------

Use $(REF replaceAll, std, regex) to replace $(REF removechars, std, string):
-------
import std.string;
import std.regex;

// old
"abc".removechars("a-z");

// new
"abc".replaceAll(regex("[a-z]"), "");
-------

Use $(REF uniq, std, algorithm, iteration) to replace $(REF squeeze, std, string):
-------
import std.algorithm;
import std.string;

// old
"hello".squeeze;

// new
"hello".uniq;
-------
2 changes: 1 addition & 1 deletion changelog/split-std-datetime.dd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $(MREF std,datetime,timezone) contains the time zone types.
$(MREF std,datetime,package) contains StopWatch and the benchmarking functions
(so, they can only be imported via std.datetime and not via a submodule). As
those functions use $(REF TickDuration,core,time) (which is being replaced by
$(REF MonoTime,core,time), they are slated for deprecation.
$(REF MonoTime,core,time), they are slated for deprecation).

$(MREF std,datetime,stopwatch) has been added. It contains versions of
StopWatch and benchmark which have almost the same API as the existing symbols,
Expand Down
29 changes: 18 additions & 11 deletions std/container/rbtree.d
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,7 @@ struct RBNode(V)

Node dup()
{
Node copy = new RBNode!V;
copy.value = value;
Node copy = new RBNode!V(null, null, null, value);
copy.color = color;
if (_left !is null)
copy.left = _left.dup();
Expand Down Expand Up @@ -801,9 +800,7 @@ if (is(typeof(binaryFun!less(T.init, T.init))))

static private Node allocate(Elem v)
{
auto result = allocate();
result.value = v;
return result;
return new RBNode(null, null, null, v);
}

/**
Expand Down Expand Up @@ -1190,7 +1187,8 @@ if (is(typeof(binaryFun!less(T.init, T.init))))
else
{
assert(ts.length == 5);
assert(ts.stableInsert(cast(Elem[])[7, 8, 6, 9, 10, 8]) == 5);
Elem[] elems = [7, 8, 6, 9, 10, 8];
assert(ts.stableInsert(elems) == 5);
assert(ts.length == 10);
assert(ts.stableInsert(cast(Elem) 11) == 1 && ts.length == 11);
assert(ts.stableInsert(cast(Elem) 7) == 0 && ts.length == 11);
Expand Down Expand Up @@ -1398,11 +1396,7 @@ assert(equal(rbt[], [5]));
size_t removeKey(U...)(U elems)
if (allSatisfy!(isImplicitlyConvertibleToElem, U))
{
Elem[U.length] toRemove;

foreach (i, e; elems)
toRemove[i] = e;

Elem[U.length] toRemove = [elems];
return removeKey(toRemove[]);
}

Expand Down Expand Up @@ -2056,3 +2050,16 @@ if ( is(typeof(binaryFun!less((ElementType!Stuff).init, (ElementType!Stuff).init
class C {}
RedBlackTree!(C, "cast(void*)a < cast(void*) b") tree;
}

@safe pure unittest // const/immutable elements (issue 17519)
{
RedBlackTree!(immutable int) t1;
RedBlackTree!(const int) t2;

import std.algorithm.iteration : map;
static struct S { int* p; }
auto t3 = new RedBlackTree!(immutable S, (a, b) => *a.p < *b.p);
t3.insert([1, 2, 3].map!(x => immutable S(new int(x))));
static assert(!__traits(compiles, *t3.front.p = 4));
assert(*t3.front.p == 1);
}
6 changes: 3 additions & 3 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -4178,8 +4178,8 @@ auto dirEntries(string path, string pattern, SpanMode mode,
* Reads a file line by line and parses the line into a single value or a
* $(REF Tuple, std,typecons) of values depending on the length of `Types`.
* The lines are parsed using the specified format string. The format string is
* passed to $(REF formattedRead, std,format), and therefore must conform to the
* format string specification outlined in $(MREF format).
* passed to $(REF formattedRead, std,_format), and therefore must conform to the
* format string specification outlined in $(MREF std, _format).
*
* Params:
* Types = the types that each of the elements in the line should be returned as
Expand All @@ -4193,7 +4193,7 @@ auto dirEntries(string path, string pattern, SpanMode mode,
* Throws:
* `Exception` if the format string is malformed. Also, throws `Exception`
* if any of the lines in the file are not fully consumed by the call
* to $(REF formattedRead, std,format). Meaning that no empty lines or lines
* to $(REF formattedRead, std,_format). Meaning that no empty lines or lines
* with extra characters are allowed.
*/
Select!(Types.length == 1, Types[0][], Tuple!(Types)[])
Expand Down