Bug 12148 – std.uuid.parseUUID should document that it changes lvalue input data
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-12T19:54:00Z
Last change time
2014-03-10T07:25:34Z
Assigned to
nobody
Creator
goldmax3000
Comments
Comment #0 by goldmax3000 — 2014-02-12T19:54:04Z
DMD 2.064.2
string s = "d8011e49-7b28-4506-8ceb-3a5bcda875d3";
auto id = parseUUID(s);
assert(s == "d8011e49-7b28-4506-8ceb-3a5bcda875d3"); // Error
After parse the string has zero length.
Comment #1 by andrej.mitrovich — 2014-02-12T23:35:18Z
Yeah, it consumes the input range. It should be documented that it does so.
Comment #2 by goldmax3000 — 2014-02-14T02:27:19Z
Maybe just remove ref keyword from definition?
Comment #3 by andrej.mitrovich — 2014-02-14T02:42:09Z
Parse functions are generally meant to consume the range, this makes them useful for input ranges (or e.g. streams I would think..)
Comment #4 by yebblies — 2014-02-15T07:47:35Z
This is working as designed (similar to the std.conv.parse functions) although the documentation does not mention this.
For a non-consuming parser for exact strings, use the constructor of UUID.