# std/mem: add sliceTo\(\), deprecate spanZ\(\), lenZ\(\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/cd7b5a37186332e90fee91dd366cba46e3c29ca0)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: cd7b5a37186332e90fee91dd366cba46e3c29ca0

Requested commit: cd7b5a37186332e90fee91dd366cba46e3c29ca0

Commit: cd7b5a37186332e90fee91dd366cba46e3c29ca0

Tree: 547ad7d4a3d3234a429f6993a7ebf52dc50049df

Author: Isaac Freund

Committer: Isaac Freund

## Message

```
std/mem: add sliceTo(), deprecate spanZ(), lenZ()

The current spanZ() function will not scan for a 0 terminator if the
type is not 0 terminated. This encourages using 0 terminated array
types to bind C arrays which hold 0 terminated strings. However, this is
a big footgun as nothing in the C type system guarantees there to be a
0 terminator at the end of the array and if there is none this becomes
Illegal Behavior in Zig.

To solve this, deprecate spanZ() and lenZ(), adding a new sliceTo()
function that always scans for the given terminator even if the type is
not sentinel terminated.

```

## Parents

- [c0369575218d3dccb69f62495de31c8e22d41ae9](https://git.cafe/gitcafe/zig/commit/c0369575218d3dccb69f62495de31c8e22d41ae9?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/cd7b5a37186332e90fee91dd366cba46e3c29ca0?format=markdown)
