mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
Add safeties for alignLeft
This commit is contained in:
committed by
Fredrik Høisæther Rasch
parent
9823c677b8
commit
177a634992
@@ -1092,8 +1092,8 @@ proc alignLeft*(s: string, count: Natural, padding = ' '): string {.noSideEffect
|
||||
## assert alignLeft("1232", 6, '#') == "1232##"
|
||||
if s.len < count:
|
||||
result = newString(count)
|
||||
for i in 0 ..< s.len:
|
||||
result[i] = s[i]
|
||||
if s.len > 0:
|
||||
result[0 .. (s.len - 1)] = s
|
||||
for i in s.len ..< count:
|
||||
result[i] = padding
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user