diff options
author | Zoom <ZoomRmc@users.noreply.github.com> | 2023-06-21 06:52:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-21 08:52:33 +0200 |
commit | 5e529b3bfa7b3ca09cde7237134acd47e47ca48c (patch) | |
tree | f85af533ea8c251a48bddac06a600069be0bcc4a /changelogs | |
parent | a345cde26e15ef8e1c905c48507195739fab4515 (diff) | |
download | Nim-5e529b3bfa7b3ca09cde7237134acd47e47ca48c.tar.gz |
`strutils.split/rsplit` now return src on an empty sep (#22136)
This is a rebase of an earlier rejected PR. Following the discussion around it, this commit provides a valid output for and edge case of an empty separator for `split` and `rsplit` routines. The empty separator is interpreted as "split by no separators" and the initial string is returned. This is consistent with the behaviour of the `set[char]` version of `split`/`rsplit` routines and unifies them all. Compared to a commit merged earlier, this one has a benefit of not using assertions that will be removed in release builds and thus still not preventing possible infinite loops (which was the earlier behaviour for this edge case for separator of type `string`). Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'changelogs')
-rw-r--r-- | changelogs/changelog_2_0_0.md | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/changelogs/changelog_2_0_0.md b/changelogs/changelog_2_0_0.md index b56a3e71c..4a0d505c8 100644 --- a/changelogs/changelog_2_0_0.md +++ b/changelogs/changelog_2_0_0.md @@ -256,8 +256,6 @@ declared when they are not available on the backend. Previously it would call `doAssert false` at runtime despite the condition being compile-time. -- `strutils.split` and `strutils.rsplit` now forbid an empty separator. - - Custom destructors now supports non-var parameters, e.g. `proc =destroy[T: object](x: T)` is valid. `proc =destroy[T: object](x: var T)` is deprecated. - Relative imports will not resolve to searched paths anymore, e.g. `import ./tables` now reports an error properly. @@ -275,6 +273,7 @@ - Changed `mimedb` to use an `OrderedTable` instead of `OrderedTableRef` to support `const` tables. - `strutils.find` now uses and defaults to `last = -1` for whole string searches, making limiting it to just the first char (`last = 0`) valid. +- `strutils.split` and `strutils.rsplit` now return a source string as a single element for an empty separator. - `random.rand` now works with `Ordinal`s. - Undeprecated `os.isvalidfilename`. - `std/oids` now uses `int64` to store time internally (before it was int32). |