From a52c07a949ef0260331021ebc3c2cb04e3763e31 Mon Sep 17 00:00:00 2001 From: Perry Hertler Date: Tue, 17 Dec 2024 18:08:45 -0600 Subject: [PATCH] formatting and updating rust --- rust-toolchain.toml | 2 +- src/packs/configuration.rs | 9 ++++++--- src/packs/creator.rs | 6 ++---- src/packs/parsing/ruby/experimental/parser.rs | 2 +- src/packs/parsing/ruby/packwerk/parser.rs | 2 +- tests/common/mod.rs | 6 ++++-- tests/create_test.rs | 15 +++++++++++---- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 52b70ad..6b1db70 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.77.2" +channel = "1.83.0" components = ["clippy", "rustfmt"] targets = ["x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu"] diff --git a/src/packs/configuration.rs b/src/packs/configuration.rs index c325cdc..c1f5e6f 100644 --- a/src/packs/configuration.rs +++ b/src/packs/configuration.rs @@ -380,7 +380,8 @@ mod tests { assert!(!actual.cache_enabled); - let expected_readme_template_path = absolute_root.join("README_TEMPLATE.md"); + let expected_readme_template_path = + absolute_root.join("README_TEMPLATE.md"); assert_eq!(actual.readme_template_path, expected_readme_template_path); } @@ -470,11 +471,13 @@ mod tests { #[test] fn with_readme_template_path() { - let absolute_root = PathBuf::from("tests/fixtures/app_with_custom_readme"); + let absolute_root = + PathBuf::from("tests/fixtures/app_with_custom_readme"); let actual = configuration::get(&absolute_root).unwrap(); let actual_readme_template_path = actual.readme_template_path; - let expected_readme_template_path = absolute_root.join("config/packs/README_EXAMPLE.md"); + let expected_readme_template_path = + absolute_root.join("config/packs/README_EXAMPLE.md"); assert_eq!(actual_readme_template_path, expected_readme_template_path); } } diff --git a/src/packs/creator.rs b/src/packs/creator.rs index ec51909..cd4e39c 100644 --- a/src/packs/creator.rs +++ b/src/packs/creator.rs @@ -62,7 +62,7 @@ pub fn create( fn readme(configuration: &Configuration, pack_name: &str) -> String { let readme_template_path = configuration.readme_template_path.clone(); - let readme_template = if readme_template_path.exists() { + if readme_template_path.exists() { std::fs::read_to_string(readme_template_path).unwrap() } else { format!( @@ -83,9 +83,7 @@ README.md should change as your public API changes. See https://github.com/rubyatscale/pks#readme for more info!", pack_name ) - }; - - readme_template + } } fn is_rails(configuration: &Configuration) -> bool { diff --git a/src/packs/parsing/ruby/experimental/parser.rs b/src/packs/parsing/ruby/experimental/parser.rs index 4a22e87..a72d4e6 100644 --- a/src/packs/parsing/ruby/experimental/parser.rs +++ b/src/packs/parsing/ruby/experimental/parser.rs @@ -25,7 +25,7 @@ struct ReferenceCollector<'a> { pub custom_associations: Vec, } -impl<'a> Visitor for ReferenceCollector<'a> { +impl Visitor for ReferenceCollector<'_> { fn on_class(&mut self, node: &nodes::Class) { // We're not collecting definitions, so no need to visit the class definitioname); let namespace_result = fetch_const_name(&node.name); diff --git a/src/packs/parsing/ruby/packwerk/parser.rs b/src/packs/parsing/ruby/packwerk/parser.rs index 7e271d2..01c64f3 100644 --- a/src/packs/parsing/ruby/packwerk/parser.rs +++ b/src/packs/parsing/ruby/packwerk/parser.rs @@ -36,7 +36,7 @@ struct ReferenceCollector<'a> { pub custom_associations: Vec, } -impl<'a> Visitor for ReferenceCollector<'a> { +impl Visitor for ReferenceCollector<'_> { fn on_class(&mut self, node: &nodes::Class) { // We're not collecting definitions, so no need to visit the class definitioname); let namespace_result = fetch_const_name(&node.name); diff --git a/tests/common/mod.rs b/tests/common/mod.rs index b90ff2c..eb09c23 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -33,7 +33,8 @@ pub fn delete_foobar() { #[allow(dead_code)] pub fn delete_foobaz() { - let directory = PathBuf::from("tests/fixtures/simple_packs_first_app/packs/foobaz"); + let directory = + PathBuf::from("tests/fixtures/simple_packs_first_app/packs/foobaz"); if let Err(err) = fs::remove_dir_all(directory) { eprintln!( "Failed to remove tests/fixtures/simple_packs_first_app/packs/foobaz during test teardown: {}", @@ -44,7 +45,8 @@ pub fn delete_foobaz() { #[allow(dead_code)] pub fn delete_foobar_app_with_custom_readme() { - let directory = PathBuf::from("tests/fixtures/app_with_custom_readme/packs/foobar"); + let directory = + PathBuf::from("tests/fixtures/app_with_custom_readme/packs/foobar"); if let Err(err) = fs::remove_dir_all(directory) { eprintln!( "Failed to remove tests/fixtures/app_with_custom_readme/packs/foobar during test teardown: {}", diff --git a/tests/create_test.rs b/tests/create_test.rs index ec9380a..42c2d94 100644 --- a/tests/create_test.rs +++ b/tests/create_test.rs @@ -67,10 +67,14 @@ See https://github.com/rubyatscale/pks#readme for more info!"); } #[test] -fn test_create_with_readme_template_default_path() -> Result<(), Box> { +fn test_create_with_readme_template_default_path() -> Result<(), Box> +{ common::delete_foobaz(); - fs::write("tests/fixtures/simple_packs_first_app/README_TEMPLATE.md", "This is a test custom README template")?; + fs::write( + "tests/fixtures/simple_packs_first_app/README_TEMPLATE.md", + "This is a test custom README template", + )?; Command::cargo_bin("pks")? .arg("--project-root") @@ -90,13 +94,16 @@ fn test_create_with_readme_template_default_path() -> Result<(), Box> common::teardown(); common::delete_foobaz(); - fs::remove_file("tests/fixtures/simple_packs_first_app/README_TEMPLATE.md")?; + fs::remove_file( + "tests/fixtures/simple_packs_first_app/README_TEMPLATE.md", + )?; Ok(()) } #[test] -fn test_create_with_readme_template_custom_path() -> Result<(), Box> { +fn test_create_with_readme_template_custom_path() -> Result<(), Box> +{ common::delete_foobar_app_with_custom_readme(); Command::cargo_bin("pks")?