Fix Issue 21233 - std.conv.parse doesn't report the number of characters consumed (#7642)

This commit is contained in:
Adela Vais 2020-11-16 10:14:43 +02:00 committed by GitHub
parent e89d9d9ce0
commit b9db8c8d60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 601 additions and 86 deletions

View file

@ -0,0 +1,15 @@
Return the number of characters consumed by `std.conv.parse`
By setting the flag `doCount` to `Yes.doCount`, the function returns a named tuple.
The tuple contains the fields `data` and `count`.
The field `data` is of type `Target` and it contains the result of the original function.
The field `count` is of type `size_t` and it contains the number of characters consumed.
The function is keeping its original behaviour otherwise.
Example:
-------
import std.typecons : Flag, Yes, No;
string s1 = "123";
auto a1 = parse!(int, string, Yes.doCount)(s1);
assert(a1.data == 123 && a1.count == 3);
-------

File diff suppressed because it is too large Load diff