On Friday, 21 May 2021 at 14:19:03 UTC, newbie wrote:
Thank you, and formatValue?

formattedWrite should handle this.

```d
@safe struct Foo {
        int x = 3;
        void toString(W)(ref W writer) if (isOutputRange!(W, char)) {
                writer.formattedWrite("Foo(%s)", x);
        }
}
Foo foo;
writeln(foo);
```

Oddly enough this form of toString works from @safe code even if it's not marked @safe, or even marked @system...

Reply via email to