deques.nim: Refactor the toDeque functionality (#15166)
This commit polishes the new proc introduced by d9ed816b10.
Changes:
- Rename to `toDeque` for more consistency with well-known procs like
`toHashSet` and `toTable`.
- Rename the `openArray` parameter. The name `arr` was potentially less
clear given that the proc can be used with a seq (or string).
- Add a `since` annotation.
- Reword the doc comment, and clarify that ordering is preserved.
- Add runnableExamples.
- Add "see also" cross linking between `initDeque` and `toDeque`.
- Remove duplicate `nextPowerOfTwo`. The `initImpl` template already
includes it.
- Implement the proc using the `items` iterator, rather than indexing.
This matches the implementation of `sets.toHashSet` and
`tables.toTable`.
- Add a test within `when isMainModule`.
- Add a changelog entry.
This commit is contained in:
parent
a528382e05
commit
6f482ab934
2 changed files with 21 additions and 5 deletions
|
|
@ -145,6 +145,9 @@
|
|||
|
||||
- Export `asyncdispatch.PDispatcher.handles` so that an external library can register them.
|
||||
|
||||
- Added `deques.toDeque`, which creates a deque from an openArray. The usage is
|
||||
similar to procs such as `sets.toHashSet` and `tables.toTable`. Previously,
|
||||
it was necessary to create an empty deque and add items manually.
|
||||
|
||||
## Language changes
|
||||
- The `=destroy` hook no longer has to reset its target, as the compiler now automatically inserts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue