Minor code style improvements

This commit is contained in:
FliegendeWurst 2021-10-01 09:19:53 +02:00
parent 7cb8ca65fc
commit bcf3c3f9ef

View File

@ -122,15 +122,13 @@ async fn real_main(mut opt: Opt) -> Result<()> {
// Load course_names.toml file // Load course_names.toml file
let course_names_path = opt.output.join("course_names.toml"); let course_names_path = opt.output.join("course_names.toml");
let course_names: HashMap<String, String>; let course_names = if fs::metadata(&course_names_path).await.is_ok() {
// file exists, try to read it
if fs::metadata(&course_names_path).await.is_ok() { toml::from_str(&fs::read_to_string(course_names_path).await.context("accessing course_names.toml")?).context("processing course_names.toml")?
fs::read_to_string(&course_names_path).await.context("reading course_names.toml")?;
course_names = toml::from_str(&fs::read_to_string(course_names_path).await?).unwrap();
} else { } else {
// If file doesn't exist, initialise course_names with empty HashMap // If file doesn't exist, initialise course_names with empty HashMap
course_names = HashMap::new(); HashMap::new()
} };
if let Some(err) = error { if let Some(err) = error {
warning!(err); warning!(err);