pad_right
fn pad_right(string s, int width, string fill) -> Result<string, string> Import
Source: use text::{pad_right}; src/text.hy Returns s with fill added at the end until it is width bytes long. fill should be one byte; longer text is returned unchanged.
Parameters#
| Name | Type |
|---|---|
s | string |
width | int |
fill | string |
Returns#
Result<string, string>
Contracts#
Checked according to --contracts (see Contracts).
ensures fill.len() != 1 || ok_len(result) == max_int(width, s.len())
ensures fill.len() == 1 || ok_len(result) == -1
Examples#
use text::{pad_right};
use tests::assert;
assert!((pad_right("ab", 4, ".") ?? "") == "ab..");
See also#
byte_len: Returns the length ofsin bytes; the same ass.len().slice: Returns the part ofsfrom byte offsetstartup to (not including)end.trim_start: Returnsswithout leading ASCII whitespace (space, tab, CR, LF).trim_end: Returnsswithout trailing ASCII whitespace (space, tab, CR, LF).trim: Returnsswithout leading and trailing ASCII whitespace (space, tab, CR, LF).rfind: Returns the byte offset of the lastneedleinhay, or-1.split_at: Splitssat byte offsetatinto the part before and the part fromaton.join: Returns thepartsconcatenated withsepbetween each pair.