Printing and Formatting
| Macros | Return type | Description |
|---|---|---|
@print(fmt, ...) |
void |
write format to stdout |
@println(fmt, ...) |
void |
write format to stdout with newline |
@format(fmt, ...) |
String |
format values into heap String |
@dbg(expr) |
expr |
debug provided expression (Debug mode only) |
Specifiers
Section titled “Specifiers”| Slot | Meaning |
|---|---|
{} |
value (Display) |
{:?} |
debug (Debug) |
{hex} |
hexadecimal |
{oct} |
octal |
{bin} |
binary |
{:.N} |
float with N decimals |
Only {:?} and {:.N} are written with a colon, the other specifiers are bare: {hex}, not {:hex}.
Display and Debug
Section titled “Display and Debug”Structs opt in through core.io interfaces. The sink is any StrWriter, so the same code feeds stdout and String:
implement Display : Point { fn display[W: StrWriter](*const self, out: *W) void { out.write_str("point"); }}