forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
follow nim-lang#8463 nim-lang#14157 and document cstring literals
- Loading branch information
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1282,6 +1282,13 @@ string from a cstring: | |
var cstr: cstring = str | ||
var newstr: string = $cstr | ||
You shouldn't modify cstring literals. Otherwise unexpected situations may happen. | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
.. code-block:: nim | ||
This comment has been minimized.
Sorry, something went wrong.
timotheecour
|
||
# this is wrong!!! | ||
var x = cstring"literals" | ||
x[1] = 'A' | ||
Structured types | ||
---------------- | ||
A variable of a structured type can hold multiple values at the same | ||
|
need to clarify that it's ok to write to a cstring if you know it originates from a regular memory location, eg:
var a = "foo"
var b: cstring = a
b[0] = 'F' # ok