1
Fork 0
mirror of https://github.com/RGBCube/embd-rs synced 2025-07-27 13:37:44 +00:00

Use our own proc-macro2 fork and don't allocate anything at release (somewhat)

This commit is contained in:
RGBCube 2024-01-05 00:22:34 +03:00
parent da1f20a409
commit 2f2ec0f0c4
No known key found for this signature in database
5 changed files with 36 additions and 19 deletions

View file

@ -4,11 +4,26 @@ A super simple file and directory embedding crate,
that loads files from the filesystem in debug mode,
allowing for quick edit-and-test cycles without compilation.
It is also super efficient, and does not heap allocate when the
files are embedded on release mode by utilizing `std::borrow::Cow`.
On release mode it falls back to `include_str!`, `include_bytes!`
and our own custom `include_dir!` implementation.
and our own custom `include_dir!`-like implementation.
## Usage
Add this to your Cargo.toml:
```toml
[dependencies]
embed = { git = "https://github.com/RGBCube/embed-rs" }
[patch.crates-io]
proc-macro2 = { git = "https://github.com/RGBCube/proc-macro2" }
```
Then you can use this crate as so:
```rs
let contents: Cow<'_, str> = embed::string!("path/to/file.txt");
let bytes: Cow<'_, [u8]> = embed::bytes!("path/to/image.png");
@ -17,6 +32,9 @@ let dir: embed::Dir = embed::dir!("path/to");
let files: Vec<embed::File> = dir.flatten();
```
I am not sure what name to publish this
crate in, lmk if you find a good one.
## License
```