~repos /rust-embed
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.
1623d294
—
Peter John 2 years ago
Merge pull request #214 from Chtau/const_upper_snake_case
- impl/src/lib.rs +4 -4
impl/src/lib.rs
CHANGED
|
@@ -97,11 +97,11 @@ fn dynamic(ident: &syn::Ident, folder_path: String, prefix: Option<&str>, includ
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
let declare_includes = quote! {
|
|
100
|
-
const
|
|
100
|
+
const INCLUDES: &[&str] = &[#(#includes),*];
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
let declare_excludes = quote! {
|
|
104
|
-
const
|
|
104
|
+
const EXCLUDES: &[&str] = &[#(#excludes),*];
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
let canonical_folder_path = Path::new(&folder_path).canonicalize().expect("folder path must resolve to an absolute path");
|
|
@@ -127,7 +127,7 @@ fn dynamic(ident: &syn::Ident, folder_path: String, prefix: Option<&str>, includ
|
|
|
127
127
|
return None;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
if rust_embed::utils::is_path_included(&rel_file_path,
|
|
130
|
+
if rust_embed::utils::is_path_included(&rel_file_path, INCLUDES, EXCLUDES) {
|
|
131
131
|
rust_embed::utils::read_file_from_fs(&canonical_file_path).ok()
|
|
132
132
|
} else {
|
|
133
133
|
None
|
|
@@ -141,7 +141,7 @@ fn dynamic(ident: &syn::Ident, folder_path: String, prefix: Option<&str>, includ
|
|
|
141
141
|
#declare_includes
|
|
142
142
|
#declare_excludes
|
|
143
143
|
|
|
144
|
-
rust_embed::utils::get_files(String::from(#folder_path),
|
|
144
|
+
rust_embed::utils::get_files(String::from(#folder_path), INCLUDES, EXCLUDES)
|
|
145
145
|
.map(|e| #map_iter)
|
|
146
146
|
}
|
|
147
147
|
}
|