summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-27 10:29:20 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-27 10:29:20 +0000
commit270eea5e23e3aeaa93aa0b483cba76cfee1f0df9 (patch)
treece89cf4d8b5189c536e9ebd89890692fc8aade2c /docs
parent08247ead8ecd05d892b98bfb12ed807bcfebfc5c (diff)
Related to #133
Diffstat (limited to 'docs')
-rw-r--r--docs/std/string.md14
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/std/string.md b/docs/std/string.md
index ae4b738..1f89e0f 100644
--- a/docs/std/string.md
+++ b/docs/std/string.md
@@ -9,14 +9,22 @@ import "std/string.zc"
fn main() {
let s = String::from("Hello");
- s.append(String::from(" World"));
+ // Ensure memory is freed
+ defer { s.free(); }
+
+ // Append requires a pointer to another String
+ let part = String::from(" World");
+ defer { part.free(); }
+
+ s.append(&part);
- println "{s}"; // Prints "Hello World"
+ // Use c_str() to print
+ println "{s.c_str()}"; // Prints "Hello World"
if (s.starts_with("Hello")) {
// ...
}
-} // s is freed automatically
+}
```
## Structure