Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crispy-strawberry/string.zig
A Rust like String type for Zig
https://github.com/crispy-strawberry/string.zig
string zig zig-package ziglang
Last synced: 14 days ago
JSON representation
A Rust like String type for Zig
- Host: GitHub
- URL: https://github.com/crispy-strawberry/string.zig
- Owner: crispy-strawberry
- License: apache-2.0
- Created: 2023-11-14T12:08:36.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-19T08:42:21.000Z (about 1 year ago)
- Last Synced: 2024-11-18T07:00:50.351Z (3 months ago)
- Topics: string, zig, zig-package, ziglang
- Language: Zig
- Homepage:
- Size: 59.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# An allocated string type
Inspired by Rust's `String` type.
Implementation mostly ported from Rust.Provides helper functions that make working with
strings easier.I try to keep names consistent with `std.ArrayList`
## Using with package manager
1. Create `build.zig.zon` in the project root if you don't already have one.
2. Add the barebones skeleton. ([this](https://pastebin.com/Kkf6KfRi) if you don't know what it looks like)
3. Inside the dependencies section add -
```
.string = .{
.url = "git+https://github.com/crispy-strawberry/string.zig#main",
}
```
4. Run `zig build` and wait for zig to complain about the hash
5. Copy the provided hash and add it besides the url like -
```
.string = .{
.url = "",
.hash = ""
}
```
6. In your `build.zig`, add -
```zig
const string = b.dependency("string", .{ .optimize = optimize, .target = target });
// Replace exe with whatever you are using.
exe.addModule("string", string.module("string"));
```
7. Now, in your source files, you can use `String` by-
```zig
const String = @import("string").String;
```
8. Enjoy :)
## Examples
```zig
const hello_world = try String.fromStr(allocator, "Hello World!");std.debug.print("{}\n", .{hello_world.isAscii()});
```