Skip to content

Commit

Permalink
syn 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Jul 25, 2023
1 parent c16e6c9 commit eddf8bc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 59 deletions.
6 changes: 3 additions & 3 deletions miniconf_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ categories = ["no-std", "config", "rust-patterns", "parsing"]
proc-macro = true

[dependencies]
syn = { version = "1.0.58", features = ["extra-traits"] }
quote = "1.0.8"
proc-macro2 = "1.0.24"
syn = { version = "2.0", features = ["extra-traits"] }
quote = "1.0"
proc-macro2 = "1.0"
45 changes: 0 additions & 45 deletions miniconf_derive/src/attributes.rs

This file was deleted.

22 changes: 14 additions & 8 deletions miniconf_derive/src/field.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::attributes::{AttributeParser, MiniconfAttribute};
use syn::{parse_quote, Generics};

pub struct StructField {
Expand All @@ -8,14 +7,21 @@ pub struct StructField {

impl StructField {
pub fn new(field: syn::Field) -> Self {
let attributes: Vec<MiniconfAttribute> = field
.attrs
.iter()
.filter(|attr| attr.path.is_ident("miniconf"))
.map(|attr| AttributeParser::new(attr.tokens.clone()).parse())
.collect();
let mut deferred = false;

let deferred = attributes.iter().any(|x| *x == MiniconfAttribute::Defer);
for attr in field.attrs.iter() {
if attr.path().is_ident("miniconf") {
attr.parse_nested_meta(|meta| {
if meta.path.is_ident("defer") {
deferred = true;
Ok(())
} else {
Err(meta.error(format!("unrecognized miniconf attribute {:?}", meta.path)))
}
})
.unwrap();
}
}

Self { deferred, field }
}
Expand Down
1 change: 0 additions & 1 deletion miniconf_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, DeriveInput};

mod attributes;
mod field;

use field::StructField;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ pub use serde;

// Re-exports
#[cfg(feature = "json")]
pub use serde_json_core;
#[cfg(feature = "json")]
pub use heapless;
#[cfg(feature = "json")]
pub use serde_json_core;
#[cfg(feature = "json")]
mod json;
#[cfg(feature = "json")]
pub use json::JsonCoreSlash;
Expand Down

0 comments on commit eddf8bc

Please sign in to comment.