Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added error when two components with same identifier are added
  • Loading branch information
g-bauer committed Dec 22, 2021
commit 4ab70c7853e3b129d757bd9e706e05ba553b5500
14 changes: 11 additions & 3 deletions src/parameter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,17 @@ where
HashMap::new();

for (substances, file) in input {
substances.iter().for_each(|identifier| {
let _ = queried.insert(identifier.to_string());
});
substances.iter().try_for_each(|identifier| {
match queried.insert(identifier.to_string()) {
true => Ok(()),
false => Err(ParameterError::IncompatibleParameters(String::from(
format!(
"tried to add substance '{}' to system but it is already present.",
identifier.to_string()
),
))),
}
})?;
let f = File::open(file)?;
let reader = BufReader::new(f);

Expand Down