strip minor improvement (#16444)

* strip minor improvement
* add more tests
* Update tests/stdlib/tstrutils.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
flywind 2020-12-23 04:57:48 -06:00 • committed by GitHub
commit 417c2509c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -2813,7 +2813,7 @@ func strip*(s: string, leading = true, trailing = true,
if leading:
while first <= last and s[first] in chars: inc(first)
if trailing:
while last >= 0 and s[last] in chars: dec(last)
while last >= first and s[last] in chars: dec(last)
result = substr(s, first, last)
func stripLineEnd*(s: var string) =