Class in fmt coil-stdlib

Buf

class Buf
Import
use fmt::{Buf};
Source: src/fmt.hy

A string builder: append pieces, then take the text with to_string.

Associated functions#

NameDescription
newCreates an empty builder.

Methods#

NameDescription
push_strAppends s.
push_intAppends n in decimal.
push_hexAppends n in lowercase hexadecimal, without a 0x prefix.
to_stringReturns the text built so far.
pad_leftPads the text on the left with fill until it is at least width bytes long, and returns the builder.
pad_rightPads the text on the right with fill until it is at least width bytes long, and returns the builder.

Examples#

use fmt::{Buf};
use tests::assert;
let b = Buf::new();
b.push_str("id=");
b.push_int(42);
b.push_str(" mask=0x");
b.push_hex(255);
assert!(b.to_string() == "id=42 mask=0xff");

See also#

↑ ↓ navigate ↵ open