Skip to content

Commit

Permalink
Merge pull request #13 from Wen-jing-Ye/patch-1
Browse files Browse the repository at this point in the history
Update README.md with a more detailed import instruction
  • Loading branch information
Aandreba authored Jun 3, 2024
2 parents 1ac5045 + a92ce55 commit 6d9c545
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,33 @@ Reference-counted pointers for Zig inspired by Rust's [`Rc`](https://doc.rust-la

## How to use

To use `zigrc`, import the `src/main.zig` file into your project, or [add it as a module](https://zig.guide/build-system/modules) on your build file.
To use `zigrc`, import the `src/root.zig` file into your project, or add it as a module by running command shown below in your project directory.

```console
# you can fetch via archive
zig fetch "https://github.com/Aandreba/zigrc/archive/refs/tags/0.4.0.tar.gz" --save=zigrc

# or fetch via git
zig fetch "git+https://github.com/Aandreba/zigrc#<ref id>" --save=zigrc
```

Then import it in your build file (`build.zig`):
```zig
pub fn build(b: *std.Build) void {
// ...
// Import the dependency
const zigrc_dep = b.dependency("zigrc", .{});
// Extract the module
const zigrc_mod = &zigrc_dep.artifact("zig-rc").root_module;
// Add the dependency as an import to your library/executable
exe.root_module.addImport("zigrc", zigrc_mod);
lib.root_module.addImport("zigrc", zigrc_mod);
unit_tests.root_module.addImport("zigrc", zigrc_mod);
// ...
}
```

## Example

Expand Down

0 comments on commit 6d9c545

Please sign in to comment.