Bug 5945 – redBlackTree printing

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-07T06:13:00Z
Last change time
2015-10-04T18:20:51Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-05-07T06:13:17Z
This little program: import std.stdio, std.container; void main() { auto t = redBlackTree(0, 7, 5, 2); writeln(t); writeln(t[]); } Prints (DMD 2.053 beta): std.container.RedBlackTree!(int).RedBlackTree [0, 2, 5, 7] But often I'd like collections to print something that's able to generate the data structure again, as in Python: >>> s = set([1, 2, 3]) >>> s set([1, 2, 3]) >>> l = [1, 2, 3] >>> l [1, 2, 3] >>> d = {1:1, 2:2, 3:3} >>> d {1: 1, 2: 2, 3: 3} This is very useful for debugging, logging, for quick scripts, etc. So I'd like one of the two (the first one?) to print something more like this instead: redBlackTree(0, 2, 5, 7) This too is acceptable: std.container.redBlackTree(0, 2, 5, 7)
Comment #1 by jack — 2015-09-02T17:38:57Z
Comment #2 by github-bugzilla — 2015-09-03T13:09:38Z
Comment #3 by github-bugzilla — 2015-10-04T18:20:51Z