spec for view types (#15424)

* spec for view types
* spec additions
* refactoring; there are two different kinds of views
* refactorings and spec additions
* enforce that view types are initialized
* enforce borrowing from the first formal parameter
* enforce lifetimes for borrowing of locals
* typo in the manual
* clarify in the implementation what a borrow operation really is
This commit is contained in:
Andreas Rumpf 2020-09-29 23:42:38 +02:00 • committed by GitHub
commit 4058801607
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 446 additions and 66 deletions

View file

@ -23,9 +23,8 @@ proc split*(s: string, seps: set[char] = Whitespace,
while last < len(s) and s[last] notin seps:
inc(last)
if splits == 0: last = len(s)
{.noSideEffect.}:
result.add toOpenArray(s, first, last-1)
result.add toOpenArray(s, first, last-1)
result.add toOpenArray(s, first, last-1)
result.add toOpenArray(s, first, last-1)
if splits == 0: break
dec(splits)
inc(last)