~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.


c3fb0c4e mbme

4 years ago
apply changes suggested in PR
Files changed (2) hide show
  1. impl/src/lib.rs +5 -10
  2. utils/src/lib.rs +1 -1
impl/src/lib.rs CHANGED
@@ -211,16 +211,11 @@ fn impl_rust_embed(ast: &syn::DeriveInput) -> TokenStream2 {
211
211
  _ => panic!("RustEmbed can only be derived for unit structs"),
212
212
  };
213
213
 
214
- let folder_path: String = {
215
- let mut it = find_attribute_values(ast, "folder").into_iter();
214
+ let mut folder_paths = find_attribute_values(ast, "folder");
216
-
217
- match (it.next(), it.next()) {
218
- (Some(folder_path), None) => folder_path,
215
+ if folder_paths.len() != 1 {
219
- _ => {
220
- panic!("#[derive(RustEmbed)] must contain one attribute like this #[folder = \"examples/public/\"]");
216
+ panic!("#[derive(RustEmbed)] must contain one attribute like this #[folder = \"examples/public/\"]");
221
- }
217
+ }
222
- }
223
- };
218
+ let folder_path = folder_paths.remove(0);
224
219
 
225
220
  let prefix = find_attribute_values(ast, "prefix").into_iter().next();
226
221
  let includes = find_attribute_values(ast, "include");
utils/src/lib.rs CHANGED
@@ -14,7 +14,7 @@ pub struct FileEntry {
14
14
 
15
15
  #[cfg(not(feature = "include-exclude"))]
16
16
  pub fn is_path_included(_path: &str, _includes: &[&str], _excludes: &[&str]) -> bool {
17
- return true;
17
+ true
18
18
  }
19
19
 
20
20
  #[cfg(feature = "include-exclude")]