Buf::pad_left
pub fn pad_left(int width, string fill) -> Buf Import
Source: use fmt::{Buf}; src/fmt.hy Pads the text on the left with fill until it is at least width bytes long, and returns the builder.
fill is repeated whole, so a multi-byte fill can overshoot width. Text
already at least width long is unchanged.
Called on a Buf value as value.pad_left(…).
Parameters#
| Name | Type |
|---|---|
width | int |
fill | string |
Returns#
Buf
Examples#
use fmt::{Buf};
use tests::assert;
let b = Buf::new();
b.push_int(7);
assert!(b.pad_left(3, "0").to_string() == "007");
See also#
Buf: A string builder: append pieces, then take the text withto_string.Buf::new: Creates an empty builder.Buf::push_str: Appendss.Buf::push_int: Appendsnin decimal.Buf::push_hex: Appendsnin lowercase hexadecimal, without a0xprefix.Buf::to_string: Returns the text built so far.Buf::pad_right: Pads the text on the right withfilluntil it is at leastwidthbytes long, and returns the builder.