use quote::{quote, quote_spanned, ToTokens};
use proc_macro2::{Literal, TokenStream};
+use std::cell::RefCell;
+
use itertools::Itertools;
/// Generates config resolver method
//dbg!(field);
let fname = &field.ident.as_ref().unwrap();
let fname_span = fname.span();
- let mut skl = None;
- let mut set_skl = |new| {
- if let Some(old) = &skl { panic!("dup SKL {} and {} for field {}",
- old, new, &fname); }
- skl = Some(new);
+ let skl = RefCell::new(None);
+ let set_skl = |new| {
+ let mut skl = skl.borrow_mut();
+ if let Some(old) = &*skl { panic!("dup SKL {} and {} for field {}",
+ old, new, &fname); }
+ *skl = Some(new);
};
let mut method = quote_spanned!{fname_span=> ordinary };
for attr in &field.attrs {
}
}
method = get_path(tmethod);
- set_skl(get_path(tskl));
+ *skl.borrow_mut() = Some(get_path(tskl));
}
}
let fname_string = fname.to_string();
let fname_lit = Literal::string( &fname_string );
- let skl = skl.expect(&format!("SKL not specified! (field {})!", fname));
+ let skl = skl.into_inner()
+ .expect(&format!("SKL not specified! (field {})!", fname));
names.push(quote!{
(#fname_lit, #skl),
// Exceptional settings
#[special(special_link, SKL::None)] pub link: LinkName,
#[per_client] pub secret: Secret,
- #[special(special_ipif, SKL::PerClient)] pub ipif: String,
+ #[global] #[special(special_ipif, SKL::PerClient)] pub ipif: String,
// Capped settings:
#[limited] pub max_batch_down: u32,
pub use std::collections::{BTreeSet, HashMap, VecDeque};
pub use std::convert::{TryFrom, TryInto};
pub use std::borrow::Cow;
+pub use std::cell::{RefCell, RefMut};
pub use std::cmp::{min, max};
pub use std::fs;
pub use std::fmt::{self, Debug, Display, Write as _};