[Issue 19982] padLeft usability issues
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 19 05:25:30 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19982
shove <shove at 163.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |shove at 163.com
--- Comment #1 from shove <shove at 163.com> ---
I think the function you want is:
std.string.leftJustify(), std.string. rightJustify().
--------------------------------
std.range.padLeft() is normal, and it returns a range. The assert in the source
file and the four lines I added are as follows:
--------------------------------
import std.algorithm.comparison : equal;
assert([1, 2, 3, 4].padLeft(0, 6).equal([0, 0, 1, 2, 3, 4]));
assert([1, 2, 3, 4].padLeft(0, 3).equal([1, 2, 3, 4]));
assert("abc".padLeft('_', 6).equal("___abc"));
assert("a string".padLeft('0', 10).equal("00a string"));
assert("a string".padLeft('0', 10).equal([48, 48, 97, 32, 115, 116, 114,
105, 110, 103]));
assert("a string".padLeft(dchar('0'), 10).equal("00a string"));
assert("a string".padLeft(dchar('0'), 10).equal([48, 48, 97, 32, 115, 116,
114, 105, 110, 103]));
--
More information about the Digitalmars-d-bugs
mailing list