follow #8463 #14157 and document cstring literals modification is not 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>
This commit is contained in:
flywind
2020-11-12 22:28:45 +08:00
committed by GitHub
parent cc882917fe
commit 4663319bf5

View File

@@ -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