# Runtime-mutating and passing around '\[\]const u8' character strings

**URL:** <https://ziggit.dev/t/runtime-mutating-and-passing-around-const-u8-character-strings/3186>\
**Category:** Help\
**Tags:** memory-management, compiler\
**Created:** [February 9, 2024, 3:11pm UTC](https://ziggit.dev/t/runtime-mutating-and-passing-around-const-u8-character-strings/3186 "2024-02-09T15:11:42Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![FObersteiner](https://ziggit.dev/user_avatar/ziggit.dev/fobersteiner/32/1177_2.png) [@FObersteiner](https://ziggit.dev/u/FObersteiner)\
**Post date:** [February 12, 2024, 5:51pm UTC](https://ziggit.dev/t/runtime-mutating-and-passing-around-const-u8-character-strings/3186/23 "2024-02-12T17:51:01Z")

</div>

> [@dee0xeed](#):
>
> A variant without sentinel terminated array (I do not think it is really needed):

finally found the time to try this, with some interesting results:

- your code works as-is with zig 0.11
- with zig 0.12-dev, I need to use `fn get(self: *ToyStr) []const u8 { ...`
  - that works as far as I can tell (debug, safe and fast mode tested)

- with zig 0.12-dev, if I replace the pointer to self with self only, `fn get(self: ToyStr) []u8 { ...`, this _ **does not work** _ - why ?

---

_[View the full topic](https://ziggit.dev/t/runtime-mutating-and-passing-around-const-u8-character-strings/3186)._
