From a2cf5b7b8088a82f9e42980b59c7d8f040662b05 Mon Sep 17 00:00:00 2001 From: litlighilit Date: Mon, 6 May 2024 08:50:46 +0800 Subject: [PATCH] fix: lower/upper/capitalize return PyStr now --- src/pylib/pystring/strmeth.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pylib/pystring/strmeth.nim b/src/pylib/pystring/strmeth.nim index 02b9c291e..165958de3 100644 --- a/src/pylib/pystring/strmeth.nim +++ b/src/pylib/pystring/strmeth.nim @@ -11,10 +11,10 @@ template casefold*(a: StringLike): string = ## Mimics Python str.casefold() -> str unicode.toLower(a) -func lower*(a: StringLike): string = toLower $a -func upper*(a: StringLike): string = toUpper $a +func lower*(a: StringLike): PyStr = toLower $a +func upper*(a: StringLike): PyStr = toUpper $a -func capitalize*(a: StringLike): string = +func capitalize*(a: StringLike): PyStr = ## make the first character have upper case and the rest lower case. ## ## while Nim's `unicode.capitalize` only make the first character upper-case. @@ -25,7 +25,7 @@ func capitalize*(a: StringLike): string = rune: Rune i = 0 fastRuneAt(s, i, rune, doInc = true) - result = $toUpper(rune) & toLower substr(s, i) + result = $toUpper(rune) + substr(s, i).lower() template seWith(seWith){.dirty.} =