Lazy formatting
Vladimir Panteleev
thecybershadow.lists at gmail.com
Mon Feb 1 15:28:02 UTC 2021
On Monday, 1 February 2021 at 00:25:42 UTC, Steven Schveighoffer
wrote:
> I have often wanted a lazy formatting feature where you aren't
> allocating but it returns a string-able thing that can be used
> as an input range. I was surprised that phobos doesn't provide
> this.
>
> Would be really awesome to have, but I think possibly it means
> we need to reengineer the lower level. Probably a phobos 2.0
> thing.
Um, do you mean something like this?
https://github.com/CyberShadow/ae/blob/904d5b6ab7a15b3ecac499ef41bb40a88fd64e1e/utils/text/package.d#L47
assert(64.formatted!"%x".text == "40");
It's not an input range (I think emitting formatted strings as an
input range without an intermediary buffer would be impractically
difficult in general), but it does use the sink toString
interface.
More information about the Digitalmars-d
mailing list