Buf
class Buf Import
Source: use fmt::{Buf}; src/fmt.hy A string builder: append pieces, then take the text with to_string.
Associated functions#
| Name | Description |
|---|---|
new | Creates an empty builder. |
Methods#
| Name | Description |
|---|---|
push_str | Appends s. |
push_int | Appends n in decimal. |
push_hex | Appends n in lowercase hexadecimal, without a 0x prefix. |
to_string | Returns the text built so far. |
pad_left | Pads the text on the left with fill until it is at least width bytes long, and returns the builder. |
pad_right | Pads 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");