Skip to content

Commit

Permalink
strutils: remove deprecated delete proc
Browse files Browse the repository at this point in the history
- remove deprecated `delete(var string, int, int)`
- removed associated tests
- updated usage of removed proc in rstgen
  • Loading branch information
saem committed Aug 6, 2022
1 parent aa11679 commit b852b1d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
2 changes: 1 addition & 1 deletion lib/packages/docutils/rstgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ proc stripTocHtml(s: string): string =
if last < 0:
# Abort, since we didn't found a closing angled bracket.
return
result.delete(first, last)
result.delete(first..last)
first = result.find('<', first)

proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
Expand Down
23 changes: 0 additions & 23 deletions lib/pure/strutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1507,29 +1507,6 @@ func delete*(s: var string, slice: Slice[int]) =
inc(j)
setLen(s, newLen)

func delete*(s: var string, first, last: int) {.rtl, extern: "nsuDelete", deprecated: "use `delete(s, first..last)`".} =
## Deletes in `s` the characters at positions `first .. last` (both ends included).
runnableExamples("--warning:deprecated:off"):
var a = "abracadabra"

a.delete(4, 5)
doAssert a == "abradabra"

a.delete(1, 6)
doAssert a == "ara"

a.delete(2, 999)
doAssert a == "ar"

var i = first
var j = min(len(s), last+1)
var newLen = len(s)-j+i
while i < newLen:
s[i] = s[j]
inc(i)
inc(j)
setLen(s, newLen)

func startsWith*(s: string, prefix: char): bool {.inline.} =
## Returns true if `s` starts with character `prefix`.
##
Expand Down
11 changes: 0 additions & 11 deletions tests/stdlib/tstrutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,6 @@ template main() =
delete(s, 0..0)
doAssert s == "b"

block: # delete(first, last)
{.push warning[deprecated]:off.}
var s = "0123456789ABCDEFGH"
delete(s, 4, 5)
doAssert s == "01236789ABCDEFGH"
delete(s, s.len-1, s.len-1)
doAssert s == "01236789ABCDEFG"
delete(s, 0, 0)
doAssert s == "1236789ABCDEFG"
{.pop.}

block: # find
doAssert "0123456789ABCDEFGH".find('A') == 10
doAssert "0123456789ABCDEFGH".find('A', 5) == 10
Expand Down

0 comments on commit b852b1d

Please sign in to comment.