~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 (3) hide show
  1. Cargo.toml +1 -1
  2. changelog.md +4 -0
  3. src/lib.rs +4 -0
Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rust-embed"
3
- version = "3.0.0"
3
+ version = "3.0.1"
4
4
  description = "Rust Custom Derive Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev"
5
5
  readme = "readme.md"
6
6
  documentation = "https://docs.rs/rust-embed"
changelog.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  Thanks to [Mcat12](https://github.com/Mcat12) for the changelog.
8
8
 
9
+ ## [3.0.1] - 2018-07-24
10
+ ### Added
11
+ - panic if the folder cannot be found
12
+
9
13
  ## [3.0.0] - 2018-06-01
10
14
  ### Changed
11
15
  - The derive attribute style so we don't need `attr_literals` and it can be used in stable rust now. Thanks to [Mcat12](https://github.com/Mcat12).
src/lib.rs CHANGED
@@ -9,6 +9,7 @@ extern crate walkdir;
9
9
  use proc_macro::TokenStream;
10
10
  use syn::*;
11
11
  use quote::Tokens;
12
+ use std::path::Path;
12
13
 
13
14
  #[cfg(debug_assertions)]
14
15
  fn generate_assets(ident: &syn::Ident, folder_path: String) -> quote::Tokens {
@@ -106,6 +107,9 @@ fn impl_rust_embed(ast: &syn::DeriveInput) -> Tokens {
106
107
  panic!("#[derive(RustEmbed)] attribute value must be a string literal");
107
108
  }
108
109
  };
110
+ if !Path::new(&folder_path).exists() {
111
+ panic!("#[derive(RustEmbed)] folder '{}' does not exist. cwd: '{}'", folder_path, std::env::current_dir().unwrap().to_str().unwrap());
112
+ };
109
113
  generate_assets(ident, folder_path)
110
114
  }
111
115