Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: ⭐️NINIKA⭐️ <DCNick3@users.noreply.github.com>
Signed-off-by: 0x009922 <43530070+0x009922@users.noreply.github.com>
  • Loading branch information
0x009922 and DCNick3 committed Apr 21, 2024
1 parent 8013a46 commit 9b613a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 5 additions & 7 deletions config/base/derive/src/lib.rs
Expand Up @@ -321,7 +321,7 @@ mod ast {

let combined = if attr_nested {
Self::Nested
}else {
} else {
Self::Parameter {
default: attr_default.unwrap_or_default(),
env: match (attr_env, attr_env_custom) {
Expand Down Expand Up @@ -397,20 +397,18 @@ mod ast {
return vec![];
}

let mut found = None;

if let syn::Type::Path(type_path) = ty {
let found = if let syn::Type::Path(type_path) = ty {
if let Some(last_segment) = type_path.path.segments.last() {
match &last_segment.arguments {
syn::PathArguments::AngleBracketed(args) if args.args.len() == 1 => {
if let syn::GenericArgument::Type(ty) =
args.args.first().expect("should be exactly 1")
{
found = Some((Some(ty), &last_segment.ident));
Some((Some(ty), &last_segment.ident))
}
}
syn::PathArguments::None => found = Some((None, &last_segment.ident)),
_ => {}
syn::PathArguments::None => Some((None, &last_segment.ident)),
_ => None,
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions config/base/src/read.rs
Expand Up @@ -73,14 +73,22 @@ impl Error {
/// and finally, construct an exhaustive error report with as many errors, accumulated along the
/// way, as possible.
pub struct ConfigReader {
sources: Vec<TomlSource>,
/// The namespace this [`ConfigReader`] is handling. All the `ParameterId` handled will be prefixed with it.
nesting: Vec<String>,
/// File sources for the config
sources: Vec<TomlSource>,
/// Environment variables source for the config
env: Box<dyn ReadEnv>,
/// Errors accumulated per each file
errors_by_source: BTreeMap<PathBuf, Vec<Report<Error>>>,
/// Errors accumulated from the environment variables
errors_in_env: Vec<Report<EnvError>>,
/// A list of all the parameters that have been requested from this reader. Used to report unused (unknown) parameters in the toml file
existing_parameters: BTreeSet<ParameterId>,
/// A list of all required parameters that have been requested, but were not found
missing_parameters: BTreeSet<ParameterId>,
/// A runtime guard to prevent dropping the [`ConfigReader`] without handing errors
bomb: DropBomb,
env: Box<dyn ReadEnv>,
}

impl Debug for ConfigReader {
Expand Down

0 comments on commit 9b613a6

Please sign in to comment.