Skip to content

Commit

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

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

Co-authored-by: Juan Carlos <[email protected]>
Co-authored-by: Andreas Rumpf <[email protected]>
  • Loading branch information
3 people authored and PMunch committed Jan 6, 2021
1 parent e5297a8 commit 37f1695
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 37f1695

Please sign in to comment.