Skip to content

Commit

Permalink
follow #8463 #14157 and document cstring literals modification is not…
Browse files Browse the repository at this point in the history
… allowed (#15878)

* follow #8463 #14157 and document cstring literals
* Update doc/manual.rst

Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
  • Loading branch information
3 people authored Nov 12, 2020
1 parent cc88291 commit 4663319
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,20 @@ string from a cstring:
var cstr: cstring = str
var newstr: string = $cstr
``cstring`` literals shouldn't be modified.

.. code-block:: nim
var x = cstring"literals"
x[1] = 'A' # This is wrong!!!
If the ``cstring`` originates from a regular memory (not read-only memory),
it can be modified:

.. code-block:: nim
var x = "123456"
var s: cstring = x
s[0] = 'u' # This is ok
Structured types
----------------
A variable of a structured type can hold multiple values at the same
Expand Down

0 comments on commit 4663319

Please sign in to comment.