https://github.com/schveiguy/betterwritef
A writef overload that works with IES and format specifiers
https://github.com/schveiguy/betterwritef
Last synced: 2 months ago
JSON representation
A writef overload that works with IES and format specifiers
- Host: GitHub
- URL: https://github.com/schveiguy/betterwritef
- Owner: schveiguy
- Created: 2024-05-20T02:58:31.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-25T04:09:55.000Z (about 1 year ago)
- Last Synced: 2025-03-23T23:32:22.699Z (2 months ago)
- Language: D
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Better Writef
This library is a small wrapper around `std.stdio.writef` that uses compile time rewrites to call writef with the given parameters and the correct format string.
Best demonstrated with an example:
```d
import std.stdio;
import schlib.io;void main()
{
string name = "Joe";
int age = 42;
writef("Hello, %s, your age in hex is %x\n", name, age);
// with better writef
writef(i"Hello, $(name), your age in hex is $(age)%x\n");
}
```Note that the format string is passed at compile time always, so you will get compiler errors for malformed strings.
Also note that only writef is overloaded for now. If this becomes more popular, I might add the others.