From 9a4d290cf87a2d0b04740cb2880c0422e791d8b6 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 16 Oct 2023 19:12:25 -0400 Subject: [PATCH] Apply more suggestions. --- src/bin_compare.rs | 10 ++++------ src/bin_foreign_document_test.rs | 17 ++++++----------- src/init_tracing.rs | 2 +- src/main.rs | 12 +++++------- tests/test_loader.rs | 2 -- tests/test_template | 28 ++++++++++++---------------- 6 files changed, 28 insertions(+), 43 deletions(-) diff --git a/src/bin_compare.rs b/src/bin_compare.rs index 4486b9d..087c2c5 100644 --- a/src/bin_compare.rs +++ b/src/bin_compare.rs @@ -15,23 +15,21 @@ mod init_tracing; #[cfg(not(feature = "tracing"))] fn main() -> Result<(), Box> { let rt = tokio::runtime::Runtime::new()?; - let result = rt.block_on(async { + rt.block_on(async { let main_body_result = main_body().await; main_body_result - }); - result + }) } #[cfg(feature = "tracing")] fn main() -> Result<(), Box> { let rt = tokio::runtime::Runtime::new()?; - let result = rt.block_on(async { + rt.block_on(async { init_telemetry()?; let main_body_result = main_body().await; shutdown_telemetry()?; main_body_result - }); - result + }) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] diff --git a/src/bin_foreign_document_test.rs b/src/bin_foreign_document_test.rs index ccd7e6c..6286571 100644 --- a/src/bin_foreign_document_test.rs +++ b/src/bin_foreign_document_test.rs @@ -21,23 +21,21 @@ mod init_tracing; #[cfg(not(feature = "tracing"))] fn main() -> Result> { let rt = tokio::runtime::Runtime::new()?; - let result = rt.block_on(async { + rt.block_on(async { let main_body_result = main_body().await; main_body_result - }); - result + }) } #[cfg(feature = "tracing")] fn main() -> Result> { let rt = tokio::runtime::Runtime::new()?; - let result = rt.block_on(async { + rt.block_on(async { init_telemetry()?; let main_body_result = main_body().await; shutdown_telemetry()?; main_body_result - }); - result + }) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] @@ -108,10 +106,9 @@ fn compare_howard_abrams() -> impl Iterator { let layer = layer.chain(compare_group("clojure-yesql-xp", || { compare_all_org_document("/foreign_documents/howardabrams/clojure-yesql-xp") })); - let layer = layer.chain(compare_group("veep", || { + layer.chain(compare_group("veep", || { compare_all_org_document("/foreign_documents/howardabrams/veep") - })); - layer + })) } fn compare_group, F: Fn() -> I, I: Iterator>( @@ -195,7 +192,6 @@ struct ResultLayer { #[derive(Debug)] struct SingleFileResult { name: String, - file_path: PathBuf, status: TestStatus, } @@ -225,7 +221,6 @@ impl SingleFile { let result = silent_compare_on_file(&self.file_path).await; Ok(SingleFileResult { name: self.name, - file_path: self.file_path, status: if let Ok(true) = result { TestStatus::Pass } else { diff --git a/src/init_tracing.rs b/src/init_tracing.rs index 84e2bf7..55e4d9b 100644 --- a/src/init_tracing.rs +++ b/src/init_tracing.rs @@ -5,7 +5,7 @@ use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; #[cfg(feature = "tracing")] use tracing_subscriber::util::SubscriberInitExt; -const SERVICE_NAME: &'static str = "organic"; +const SERVICE_NAME: &str = "organic"; // Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits. diff --git a/src/main.rs b/src/main.rs index 6cdd851..b034b18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,13 +23,12 @@ fn main() -> Result<(), Box> { #[cfg(feature = "tracing")] fn main() -> Result<(), Box> { let rt = tokio::runtime::Runtime::new()?; - let result = rt.block_on(async { + rt.block_on(async { init_telemetry()?; let main_body_result = main_body(); shutdown_telemetry()?; main_body_result - }); - result + }) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] @@ -70,10 +69,9 @@ fn run_parse_on_file>(org_path: P) -> Result<(), Box Result<(), Box> {{ async fn autogen_la_{name}() -> Result<(), Box> {{ let org_path = "{path}"; let org_contents = std::fs::read_to_string(org_path).expect("Read org file."); - let global_settings = {{ - let mut global_settings = organic::settings::GlobalSettings::default(); - global_settings.list_allow_alphabetical = true; - global_settings + let global_settings = organic::settings::GlobalSettings {{ + list_allow_alphabetical: true, + ..Default::default() }}; assert!(organic::compare::run_anonymous_compare_with_settings(org_contents.as_str(), &global_settings, false).await?); Ok(()) @@ -28,10 +27,9 @@ async fn autogen_la_{name}() -> Result<(), Box> {{ async fn autogen_t1_{name}() -> Result<(), Box> {{ let org_path = "{path}"; let org_contents = std::fs::read_to_string(org_path).expect("Read org file."); - let global_settings = {{ - let mut global_settings = organic::settings::GlobalSettings::default(); - global_settings.tab_width = 1; - global_settings + let global_settings = organic::settings::GlobalSettings {{ + tab_width: 1, + ..Default::default() }}; assert!(organic::compare::run_anonymous_compare_with_settings(org_contents.as_str(), &global_settings, false).await?); Ok(()) @@ -42,10 +40,9 @@ async fn autogen_t1_{name}() -> Result<(), Box> {{ async fn autogen_t16_{name}() -> Result<(), Box> {{ let org_path = "{path}"; let org_contents = std::fs::read_to_string(org_path).expect("Read org file."); - let global_settings = {{ - let mut global_settings = organic::settings::GlobalSettings::default(); - global_settings.tab_width = 16; - global_settings + let global_settings = organic::settings::GlobalSettings {{ + tab_width: 16, + ..Default::default() }}; assert!(organic::compare::run_anonymous_compare_with_settings(org_contents.as_str(), &global_settings, false).await?); Ok(()) @@ -56,10 +53,9 @@ async fn autogen_t16_{name}() -> Result<(), Box> {{ async fn autogen_odd_{name}() -> Result<(), Box> {{ let org_path = "{path}"; let org_contents = std::fs::read_to_string(org_path).expect("Read org file."); - let global_settings = {{ - let mut global_settings = organic::settings::GlobalSettings::default(); - global_settings.odd_levels_only = organic::settings::HeadlineLevelFilter::Odd; - global_settings + let global_settings = organic::settings::GlobalSettings {{ + odd_levels_only: organic::settings::HeadlineLevelFilter::Odd, + ..Default::default() }}; assert!(organic::compare::run_anonymous_compare_with_settings(org_contents.as_str(), &global_settings, false).await?); Ok(())