std::display
The Display interface: a value as a person reads it, what "${value}"
and io.print write. Debug is the developer-facing form; the table of
how every built-in type renders in each is on
std::debug.
Import with import std::display.
Exports
Section titled “Exports”Interfaces
interface Display
Section titled “interface Display”interface Display fn to_string(value: self) -> String end
Protocol for converting a value to a String a person reads.
io.print and string interpolation ("${value}") write a value’s
Display form, so a type with an impl prints as the built-in types
do. The interface a typed literal’s handler names for its slot values
extends Display, so every interpolated value has a text form.
Int, Float, Decimal, Bool and String implement Display, and
so does a collection whose elements do. To implement it for a custom
type:
pub struct Greeter name: String end impl Display for Greeter fn to_string(g: Greeter) -> String "hi ${g.name}" end end
Display.to_string
Section titled “Display.to_string”fn to_string(value: self) -> String
interface Display