Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into shared-style
Browse files Browse the repository at this point in the history
  • Loading branch information
cikzh committed Mar 26, 2024
2 parents e1c5d72 + 641db3e commit 430c75c
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,18 @@ impl World for PdfWorld {
/// done at compile time.
macro_rules! include_filedata {
($path:literal) => {
if cfg!(debug) {
// we are leaking the data into a static slice
Box::leak(std::fs::read($path).unwrap().into_boxed_slice())
} else {
include_bytes!(concat!("../", $path)) as &'static [u8]
{
#[cfg(debug_assertions)]
fn filedata_init() -> &'static [u8] {
Box::leak(std::fs::read($path).unwrap().into_boxed_slice())
}

#[cfg(not(debug_assertions))]
fn filedata_init() -> &'static [u8] {
include_bytes!(concat!("../", $path)) as &'static [u8]
}

filedata_init()
}
};
}
Expand All @@ -143,11 +150,18 @@ macro_rules! include_filedata {
/// done at compile time.
macro_rules! include_strdata {
($path:literal) => {
if cfg!(debug) {
// we are leaking the data into a static string slice
Box::leak(std::fs::read_to_string($path).unwrap().into_boxed_str())
} else {
include_str!(concat!("../", $path)) as &'static str
{
#[cfg(debug_assertions)]
fn strdata_init() -> &'static str {
Box::leak(std::fs::read_to_string($path).unwrap().into_boxed_str())
}

#[cfg(not(debug_assertions))]
fn strdata_init() -> &'static str {
include_str!(concat!("../", $path)) as &'static str
}

strdata_init()
}
};
}
Expand Down

0 comments on commit 430c75c

Please sign in to comment.