view types: spec changes (#18226)
* view types: spec changes * Update doc/manual_experimental.rst Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> * Update doc/manual_experimental.rst Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
parent
3481ff6172
commit
2ea7287217
3 changed files with 21 additions and 24 deletions
|
|
@ -9,8 +9,9 @@ import tables
|
|||
const
|
||||
Whitespace = {' ', '\t', '\n', '\r'}
|
||||
|
||||
proc split*(s: string, seps: set[char] = Whitespace,
|
||||
maxsplit: int = -1): Table[int, openArray[char]] =
|
||||
proc split*(s: string, seps: set[char] = Whitespace, maxsplit: int = -1): Table[int, openArray[char]] #[tt.Error
|
||||
'result' borrows from the immutable location 's' and attempts to mutate it
|
||||
]# =
|
||||
var last = 0
|
||||
var splits = maxsplit
|
||||
result = initTable[int, openArray[char]]()
|
||||
|
|
@ -22,9 +23,7 @@ proc split*(s: string, seps: set[char] = Whitespace,
|
|||
if splits == 0: last = len(s)
|
||||
result[first] = toOpenArray(s, first, last-1)
|
||||
|
||||
result[first][0] = 'c' #[tt.Error
|
||||
attempt to mutate a borrowed location from an immutable view
|
||||
]#
|
||||
result[first][0] = 'c'
|
||||
|
||||
if splits == 0: break
|
||||
dec(splits)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue