[Issue 24610] New: Basic range-based `toString` not recognized
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 16 08:58:52 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24610
Issue ID: 24610
Summary: Basic range-based `toString` not recognized
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: maxsamukha at gmail.com
import std.array;
import std.format;
struct S
{
void toString(Output)(ref Output output)
{
import std.range: put;
output.put("S");
}
}
void main()
{
S s;
auto output = appender!(char[]);
s.toString(output);
assert(output[] == "S"); // ok
output.clear();
formattedWrite!"%s"(output, s);
import std.stdio;
assert(output[] == "S"); // fail
}
The `toString` is implemented according to the spec
(https://dlang.org/phobos/std_format_write.html), and the formatter should use
it.
--
More information about the Digitalmars-d-bugs
mailing list