~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git
Discussions: https://groups.google.com/g/rust-embed-devs

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


Files changed (2) hide show
  1. impl/src/lib.rs +0 -3
  2. src/utils.rs +1 -1
impl/src/lib.rs CHANGED
@@ -15,9 +15,6 @@ mod utils;
15
15
 
16
16
  #[cfg(all(debug_assertions, not(feature = "debug-embed")))]
17
17
  fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
18
- use std::env::current_dir;
19
- // resolve relative to current path
20
- let folder_path = utils::path_to_str(current_dir().unwrap().join(folder_path));
21
18
  quote!{
22
19
  impl #ident {
23
20
  pub fn get(file_path: &str) -> Option<impl AsRef<[u8]>> {
src/utils.rs CHANGED
@@ -28,6 +28,6 @@ pub fn get_files(folder_path: String) -> impl Iterator<Item = FileEntry> {
28
28
  })
29
29
  }
30
30
 
31
- pub fn path_to_str<P: AsRef<std::path::Path>>(p: P) -> String {
31
+ fn path_to_str<P: AsRef<std::path::Path>>(p: P) -> String {
32
32
  p.as_ref().to_str().expect("Path does not have a string representation").to_owned()
33
33
  }