add runnableExamples for prepareStrMutation (#17227)

* Update lib/system.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
flywind 2021-03-02 19:52:07 +08:00 • committed by GitHub
commit dfa0a6b4a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -171,7 +171,7 @@ proc nimPrepareStrMutationV2(s: var NimStringV2) {.compilerRtl, inline.} =
proc prepareStrMutation*(s: var string) {.inline.} =
# string literals are "copy on write", so you need to call
# `prepareStrMutation` before modifying the strings.
# `prepareStrMutation` before modifying the strings via `addr`.
{.cast(noSideEffect).}:
let s = unsafeAddr s
nimPrepareStrMutationV2(cast[ptr NimStringV2](s)[])