Immutability and other attributes, please review
Roman D. Boiko
rb at d-coding.com
Fri Jun 15 03:45:29 PDT 2012
On Friday, 15 June 2012 at 10:01:42 UTC, Dmitry Olshansky wrote:
> Suggest you revisit toNode function as it does return
> something strange :)
>
> Just looking at first - last lines:
> pure nothrow auto toNode(R)(R range, immutable(Maybe!Node)
> parent) if(isInputRange!R && hasLength!R)
>
> ....
> auto result = new Node[](range.length);
> foreach(e; range) result ~= toNode2(e);
> return cast(immutable) range; // <<<<---- WAT
> }
>
> And no need to cast to immutable, compiler will infer things
> automatically since it's pure. (and correctly for both
> mutable/immutable)
Thanks, fixed. This is the result of not writing tests first :)
More information about the Digitalmars-d-learn
mailing list