mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
Fix Issue 21233 - std.conv.parse doesn't report the number of characters consumed (#7642)
This commit is contained in:
parent
e89d9d9ce0
commit
b9db8c8d60
2 changed files with 601 additions and 86 deletions
15
changelog/conv_parse_count.dd
Normal file
15
changelog/conv_parse_count.dd
Normal 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);
|
||||
-------
|
672
std/conv.d
672
std/conv.d
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue