commit 79b55532d74c4b1b0d6b1a1a1846073a4363f60a
parent ebfbd177278350b9bef485063c09b09dc545e3bb
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 5 Feb 2021 12:13:39 -0500
fmt: accept runes in formattable
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fmt/fmt.ha b/fmt/fmt.ha
@@ -18,7 +18,7 @@ use strings;
use types;
// Tagged union of all types which are formattable.
-export type formattable = (...types::numeric | uintptr | str | *void);
+export type formattable = (...types::numeric | uintptr | str | rune | *void);
// Formats text for printing writes it to [os::stdout].
export fn printf(fmt: str, args: formattable...) (io::error | size) =
@@ -97,6 +97,7 @@ fn scan_uint(r: rune, iter: *strings::iterator) uint = {
fn format(out: *io::stream, arg: formattable) void = match (arg) {
s: str => io::write(out, strings::to_utf8(s)),
+ r: rune => io::write(out, utf8::encode_rune(r)),
n: types::numeric => {
let s = strconv::numerictos(n);
io::write(out, strings::to_utf8(s));