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


1385925a Mcat12

6 years ago
Show a help message if the folder was not found and includes a variable
Files changed (1) hide show
  1. impl/src/lib.rs +10 -1
impl/src/lib.rs CHANGED
@@ -128,11 +128,20 @@ fn impl_rust_embed(ast: &syn::DeriveInput) -> Tokens {
128
128
  let folder_path = shellexpand::full(&folder_path).unwrap().to_string();
129
129
 
130
130
  if !Path::new(&folder_path).exists() {
131
- panic!(
131
+ let mut message = format!(
132
132
  "#[derive(RustEmbed)] folder '{}' does not exist. cwd: '{}'",
133
133
  folder_path,
134
134
  std::env::current_dir().unwrap().to_str().unwrap()
135
135
  );
136
+
137
+ // Add a message about the interpolate-folder-path feature if the path may
138
+ // include a variable
139
+ if folder_path.contains("$") && cfg!(not(feature = "interpolate-folder-path")) {
140
+ message += "\nA variable has been detected. RustEmbed can expand variables \
141
+ when the `interpolate-folder-path` feature is enabled.";
142
+ }
143
+
144
+ panic!(message);
136
145
  };
137
146
 
138
147
  generate_assets(&ast.ident, folder_path)