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

Make bytes actually bytes

This commit is contained in:
RGBCube 2023-12-21 15:45:46 +03:00
parent e77562e096
commit 2dd76f6494
No known key found for this signature in database
2 changed files with 3 additions and 3 deletions

View file

@ -9,8 +9,8 @@ On release mode it falls back to `include_str!`, `include_bytes!` and `include_d
## Usage ## Usage
```rs ```rs
let contents: String = embed::string!("path/to/file.txt"); let contents: Cow<'_, str> = embed::string!("path/to/file.txt");
let bytes: Vec<u8> = embed::bytes!("path/to/image.png"); let bytes: Cow<'_, [u8]> = embed::bytes!("path/to/image.png");
``` ```
## License ## License

View file

@ -46,7 +46,7 @@ macro_rules! bytes {
.expect("embed: file has no parent") .expect("embed: file has no parent")
.join($path); .join($path);
Cow::<'static, str>::Owned(fs::read_to_string(&file).unwrap_or_else(|error| { Cow::<'static, [u8]>::Owned(fs::read(&file).unwrap_or_else(|error| {
panic!( panic!(
"embed: failed to read file {file}: {error}", "embed: failed to read file {file}: {error}",
file = file.display() file = file.display()