Format

drug drug2004 at bk.ru
Fri May 21 13:59:13 UTC 2021


21.05.2021 16:45, newbie пишет:
> I am following 
> https://wiki.dlang.org/Defining_custom_print_format_specifiers, why sink 
> and formatValue are not @safe? What are the best practice for toString 
> in safe code? Thank you

sink is obsolete now, use W(riter)

```D
import std.range : isOutputRange;

void toString(W)(ref W writer) const
	if (isOutputRange!(W, char))
{
	// your stuff
}
```
writer can be @safe, @nogc, nothrow etc like you want


More information about the Digitalmars-d-learn mailing list