~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git

rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.


03ec2aa6 Luka Dornhecker

7 years ago
add debug-embed feature to allow embedding in debug builds
Files changed (2) hide show
  1. Cargo.toml +1 -0
  2. src/lib.rs +2 -2
Cargo.toml CHANGED
@@ -26,6 +26,7 @@ rocket_codegen = { version = "0.3.6", optional = true }
26
26
  rocket_contrib = { version = "0.3.6", optional = true }
27
27
 
28
28
  [features]
29
+ debug-embed = []
29
30
  nightly = ["rocket", "rocket_codegen", "rocket_contrib"]
30
31
  actix = ["actix-web", "mime_guess"]
31
32
 
src/lib.rs CHANGED
@@ -11,7 +11,7 @@ use quote::Tokens;
11
11
  use std::path::Path;
12
12
  use syn::*;
13
13
 
14
- #[cfg(debug_assertions)]
14
+ #[cfg(all(debug_assertions, not(feature = "debug-embed")))]
15
15
  fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
16
16
  quote!{
17
17
  impl #ident {
@@ -41,7 +41,7 @@ fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
41
41
  }
42
42
  }
43
43
 
44
- #[cfg(not(debug_assertions))]
44
+ #[cfg(any(not(debug_assertions), feature = "debug-embed"))]
45
45
  fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
46
46
  use walkdir::WalkDir;
47
47
  let mut values = Vec::<Tokens>::new();