~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 (2) hide show
  1. impl/Cargo.toml +1 -1
  2. impl/src/lib.rs +7 -5
impl/Cargo.toml CHANGED
@@ -17,7 +17,7 @@ proc-macro = true
17
17
  [dependencies]
18
18
  rust-embed-utils = { version = "7.5.0", path = "../utils"}
19
19
 
20
- syn = { version = "1", default-features = false, features = ["derive", "parsing", "proc-macro"] }
20
+ syn = { version = "2", default-features = false, features = ["derive", "parsing", "proc-macro"] }
21
21
  quote = "1"
22
22
  proc-macro2 = "1"
23
23
  walkdir = "2.3.1"
impl/src/lib.rs CHANGED
@@ -7,7 +7,7 @@ extern crate proc_macro;
7
7
  use proc_macro::TokenStream;
8
8
  use proc_macro2::TokenStream as TokenStream2;
9
9
  use std::{env, path::Path};
10
- use syn::{Data, DeriveInput, Fields, Lit, Meta, MetaNameValue};
10
+ use syn::{Data, DeriveInput, Expr, ExprLit, Fields, Lit, Meta, MetaNameValue};
11
11
 
12
12
  fn embedded(ident: &syn::Ident, folder_path: String, prefix: Option<&str>, includes: &[String], excludes: &[String]) -> TokenStream2 {
13
13
  extern crate rust_embed_utils;
@@ -210,10 +210,12 @@ fn find_attribute_values(ast: &syn::DeriveInput, attr_name: &str) -> Vec<String>
210
210
  ast
211
211
  .attrs
212
212
  .iter()
213
- .filter(|value| value.path.is_ident(attr_name))
213
+ .filter(|value| value.path().is_ident(attr_name))
214
- .filter_map(|attr| attr.parse_meta().ok())
215
- .filter_map(|meta| match meta {
214
+ .filter_map(|attr| match &attr.meta {
215
+ Meta::NameValue(MetaNameValue {
216
- Meta::NameValue(MetaNameValue { lit: Lit::Str(val), .. }) => Some(val.value()),
216
+ value: Expr::Lit(ExprLit { lit: Lit::Str(val), .. }),
217
+ ..
218
+ }) => Some(val.value()),
217
219
  _ => None,
218
220
  })
219
221
  .collect()