Skip to content

Commit 37f1695

Browse files
ringaboutjuancarlospacoAraq
authored andcommitted
follow nim-lang#8463 nim-lang#14157 and document cstring literals modification 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]>
1 parent e5297a8 commit 37f1695

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/manual.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,20 @@ string from a cstring:
12801280
var cstr: cstring = str
12811281
var newstr: string = $cstr
12821282
1283+
``cstring`` literals shouldn't be modified.
1284+
1285+
.. code-block:: nim
1286+
var x = cstring"literals"
1287+
x[1] = 'A' # This is wrong!!!
1288+
1289+
If the ``cstring`` originates from a regular memory (not read-only memory),
1290+
it can be modified:
1291+
1292+
.. code-block:: nim
1293+
var x = "123456"
1294+
var s: cstring = x
1295+
s[0] = 'u' # This is ok
1296+
12831297
Structured types
12841298
----------------
12851299
A variable of a structured type can hold multiple values at the same

0 commit comments

Comments
 (0)