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


e269d1c5 Mark Drobnak

6 years ago
Merge pull request #70 from pyros2097/fix/better-error-messages
Files changed (1) hide show
  1. impl/src/lib.rs +3 -7
impl/src/lib.rs CHANGED
@@ -105,15 +105,11 @@ fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
105
105
  }
106
106
  }
107
107
 
108
- fn help() -> ! {
109
- panic!("#[derive(RustEmbed)] should contain one attribute like this #[folder = \"examples/public/\"]");
110
- }
111
-
112
108
  fn impl_rust_embed(ast: &syn::DeriveInput) -> Tokens {
113
109
  match ast.body {
114
- Body::Enum(_) => help(),
110
+ Body::Enum(_) => panic!("RustEmbed cannot be derived for enums"),
115
111
  Body::Struct(ref data) => match data {
116
- &VariantData::Struct(_) => help(),
112
+ &VariantData::Struct(_) => panic!("RustEmbed can only be derived for unit structs"),
117
113
  _ => {}
118
114
  },
119
115
  };
@@ -121,7 +117,7 @@ fn impl_rust_embed(ast: &syn::DeriveInput) -> Tokens {
121
117
  let attribute = ast.attrs.iter().map(|attr| &attr.value).find(|value| value.name() == "folder");
122
118
  let literal_value = match attribute {
123
119
  Some(&MetaItem::NameValue(_, ref literal)) => literal,
124
- _ => help(),
120
+ _ => panic!("#[derive(RustEmbed)] should contain one attribute like this #[folder = \"examples/public/\"]"),
125
121
  };
126
122
  let folder_path = match literal_value {
127
123
  &Lit::Str(ref val, _) => val.clone(),